home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Mac OS Development Toolkit / Automation Essentials 2.3.0 / Host Automation Folder / Clouseau libs / TargetControl.lib < prev    next >
Encoding:
Text File  |  1998-03-19  |  145.9 KB  |  4,011 lines  |  [TEXT/MPS ]

  1. #########################################################################
  2. #########################################################################
  3. ##                     Copyright © Apple Computer, Inc. 1993-1997
  4. ##                                All rights reserved
  5. #########################################################################
  6. #########################################################################
  7. #    
  8. #    Library:        TargetControl.lib
  9. #
  10. #    Version:        2.1.4
  11. #    
  12. #    Description:    
  13. #        Contains all kinds of tasks to control the target. Many of 
  14. #        these tasks were in other libraries originally, some in the 
  15. #        Clouseau Project and others in the LQ Project.
  16. #    
  17. #    Contains:
  18. #        open_control_panel()
  19. #        alias_control_panel()
  20. #        key_repeat_off()
  21. #        reset_target_info()
  22. #        target_machine()
  23. #        target_processor()
  24. #        target_fpu()
  25. #        get_target_info()
  26. #        target_control()
  27. #        SelectPrinter()
  28. #        SelectDesktopPrinter()
  29. #        SelectATImageWriter()
  30. #        SelectImageWriter()
  31. #        SelectLaserWriter()
  32. #        SelectLaserWriter300()
  33. #        SelectLaserWriter8()
  34. #        SelectLWSelect310()
  35. #        SelectLQATImageWriter()
  36. #        SelectLQImageWriter()
  37. #        SelectPersonalLaserWriterSC()
  38. #        SelectPersonalLWLS()
  39. #        SelectStyleWriter()
  40. #        SelectStyleWriterII()
  41. #        SelectColorSW2400()
  42. #        SelectLaserWriterGX()
  43. #        SelectColorSW2400GX()
  44. #        SelectPDDMakerGX()
  45. #        ensure_screen_depth()
  46. #        sys_vers()
  47. #        VerifyGetInfo()
  48. #        CheckExternalToolVersions()
  49. #        SetUpGeneralControls()
  50. #        reset()
  51. #        target_info()
  52. #        CPUstic()
  53. #        restart_target()
  54. #        EH_CrashRecover()
  55. #        setMacsBugMacro()
  56. #        MacsBugLog()
  57. #        EnableProgramLinking()
  58. #    
  59. #    History:
  60. #        Date:        By:        Changes:
  61. #        03/15/93    SBR        Created for use with Launchquits (LQ Project)
  62. #        02/19/94    SBR        Moved to Clouseau Project for everyone to use
  63. #        04/09/95    SBR        Added support for QD GX Printer select:
  64. #                            Created: VerifyGetInfo(), SelectPDDMakerGX(),
  65. #                            Modified: SelectPrinter(), SelectDesktopPrinter(), 
  66. #                            reset_target_info().
  67. #        07/19/95    SBR        Moved in CheckExternalToolVersions and 
  68. #                            TurnOffShutdownWarning from Launchquit Script.
  69. #                            Added support for ISO: OnTarget extn and ctrl
  70. #                            gathering once again!
  71. #        08/01/95    SBR        Radar 1275886: use AEPost to store target info.
  72. #        08/05/95    SBR        Radar 1272723: removed dependencies on MathTool.
  73. #        09/04/95    SBR        Radar 1273927: updated header.
  74. #        09/05/95    SBR        MSO added SelectColorSW2400.
  75. #        06/01/96    SBR/MSO    Updated copyright header
  76. #        06/01/96    MSO        Radar 1293546: Added SelectColorSW2400GX task 
  77. #                            Radar 1293559: Added SelectLaserWriterGX task
  78. #                            Radar 1294574: Documented pSystemFiles parameter in reset_target_info
  79. #        08/27/96    BRL        OnTarget extn and ctrl gathering removed once again!
  80. #                            mostly in reset_target_info...
  81. #                            Other mods for emergency launch/quit repairs
  82. #                            (fileTool/OnTarget version references removed)
  83. #                            set ScrollPrompt off
  84. #        09/27/96    BRL/MSO    Added SPEC exception handling
  85. #        12/03/96    Masa    changed call to abort_script(). Radar 1185040
  86. #        01/21/97    SBR        Deleted older exception code and comments.
  87. #        01/27/97    SBR        Added FileToolHost.vuLib, removed VUAidFKEY.lib.
  88. #        04/10/97    SBR        Added EnableProgramLinking().
  89. #        04/17/97    SBR        Fixed Radar 1377545 in restart_target().
  90. #    
  91. #########################################################################
  92. #########################################################################
  93.  
  94. Libraries
  95.     "68040CacheSwitchCP.lib",
  96.     "Additions.lib",
  97.     "Clouseau.lib",
  98.     "ExceptionHandling.lib",
  99.     "MemoryCP.lib",
  100.     "Message.lib",
  101.     "Report.lib",
  102.     "VUAid.lib",
  103.     
  104.     "FileTool.vuLib",    # external to Clouseau (see SPEC S & L)
  105.     "FileToolHost.vuLib",    # external to Clouseau (see SPEC S & L)
  106.     "OnTarget.Lib",        # external to Clouseau (see SPEC S & L)
  107.     
  108.     "AEPost.vuLib",        # Added for Radar 1276224
  109.     "Arbitrator.vu",
  110.     "Ivy Tool Declaration.vulib";
  111.     
  112. #########################################################################
  113. #    task                    open_control_panel(name, closeWindow, v_level)
  114. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  115. #    Description:    Opens a system 7.0 type control panel passed in by name.
  116. #                    The control panel opens only the window control panels
  117. #                    if no name is passed.
  118. #    Parameters:        name:            name of control panel to open
  119. #                    closeCPWindow:    true:    close Control Panels window after 
  120. #                                            success or failure
  121. #                                    false:    leave Control Panels window open
  122. #                                    ignored if name is empty
  123. #                    v_level:        verbosity level for log output
  124. #    Returns:        true if it was successfully opened
  125. #                    false if an error occured while attempting to open it.  
  126. #    Examples:        open_control_panel("Map");
  127. #                    open_control_panel();
  128. #    Assumptions:    None
  129. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  130. #    History:
  131. #        7/25/90 Alan Liu        Creation as part of ControlPanelLib.vu for 007
  132. #        3/4/92    Jason Marsh        Incorporated into Clouseau.Lib
  133. #        05/27/93    SBR            Try to select control panel's alias in the Apple Menu
  134. #                                This depends on the new select_menuItem() in Clouseau.lib
  135. #        05/27/93    SBR            Fixed closing Control Panels window for success and failure
  136. #        05/27/93    SBR            Added v_level to errors
  137. #        11/08/93    SBR            Added closeCPWindow parameter
  138. #        11/25/95    SBR            Apple Menu name does not have to end with ' alias' 
  139. #        09/27/96    BRL/MSO        Added SPEC exception handling
  140. #########################################################################
  141. task    open_control_panel(name:="", closeCPWindow := true, v_level := 5)
  142. begin
  143.     error := false;
  144.     noErr := true;
  145.  
  146.     if name
  147.         temp := select_menuItem(/{name}≈/,1,,,v_level);    #first try opening the alias in the Apple menu    
  148.     if not temp 
  149.     begin
  150.         ### Select Controls panel menu item to open control panels
  151.         if (select_descriptor([menuitem t:"Control Panels" m:1],, v_level) = error)
  152.             return RIncomplete("open_control_panel: could not select Control Panels menu item");
  153.     
  154.         if (await_presence([window t:"Control Panels" o:1]) = error)
  155.             return error;        
  156.         
  157.         if name = "" 
  158.             return(noErr);                #return if no specific control panel is specified
  159.         
  160.         ### Save the names and rectangles of the current windows for restoration later
  161.         try 
  162.             match [window t:$windowNames r:$windowRects];
  163.         catch theError
  164.             ExceptionDispatcher(theError,,{"match in open_control_panel() gathering", {name, closeCPWindow, v_level}});
  165.  
  166.  
  167.         ### Type in the name of the control panel and open it. If closeCPWindow is true, close
  168.         ### the Control Panels window behind it, otherwise leave it open.
  169.         
  170.         type_keys({name, 'latch', commandKey, "i"},v_level);
  171.         
  172.         if not _MatchBoolean([window t:/≈{name}≈/], true) 
  173.         begin
  174.             if closeCPWindow
  175.                 key_eq('w',,v_level);
  176.             key_eq('w',,v_level);
  177.             return RIncomplete("open_control_panel: Could not find control panel named: {name}", v_level);
  178.         end;
  179.         else 
  180.         begin
  181.             key_eq('w',,v_level);
  182.             
  183.             if closeCPWindow
  184.                 key_eq('o',5,v_level);        # close the Control Panels window with cmd-option-o
  185.             else 
  186.                 key_eq('o',,v_level);        # leave open the Control Panels window with cmd-o
  187.         end;
  188.     end;
  189.     
  190.     ### Handle the case where the control panel does not open
  191.     if not await_presence([window t:name o:1])
  192.     begin
  193.         errMessage := '';
  194.  
  195.         ## check to see if a dialog came up
  196.         if _MatchBoolean([window s:dialog o:1], true)
  197.         begin
  198.             errMessage := _Match([statictext w:1], true).t;
  199.             _Type({ enterKey });            # Dismiss dialog
  200.             
  201.             errMessage := "open_control_panel: Unexpected dialog opening {name} control panel: " +
  202.                             errMessage;
  203.         end;
  204.  
  205.         frontWindow := _Match([window o:1], true);
  206.         if not (isMember(frontWindow.t, windowNames) = isMember(frontWindow.r, windowRects))
  207.             key_eq('w',,v_level);
  208.         
  209.         if not errMessage
  210.             errMessage:= "open_control_panel: Found {name} but it did not open correctly";
  211.  
  212.         return RIncomplete(errMessage, v_level);
  213.     end;
  214.     
  215.     return noErr;    ### Everything worked
  216. end;
  217.  
  218.  
  219. #########################################################################
  220. #    task                    alias_control_panel(name, v_level)
  221. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  222. #    Description:    Creates an alias to a system 7.0 type control panel passed 
  223. #                    in by name, and put it in the Apple Menu Items folder.
  224. #    Parameters:        name:            name of control panel to open
  225. #                    v_level:        verbosity level for log output
  226. #    Returns:        true if it was successfully opened by alias
  227. #                    false if an error occured  
  228. #    Examples:        alias_control_panel('Memory');
  229. #    Assumptions:    VUAid external tool
  230. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  231. #    History:
  232. #        05/27/93    SBR        created
  233. #        09/03/94    SBR        Added error handling for Get Info on alias
  234. #########################################################################
  235. task    alias_control_panel(name := 'Memory', v_level := 4)
  236. begin
  237.     controlPanelsFolder := VUAid('findfolder',{'ctrl'}) + ":";
  238.     if not VUAid('iconlocation', {controlPanelsFolder + name})    # check if item exists
  239.     begin
  240.         RIncomplete("alias_control_panel: Could not find control panel: {name}", v_level);
  241.         RStatus("If it is there anyway, rebuild the desktop for the startup volume.", v_level);
  242.         return false;
  243.     end;
  244.     appleMenuItemsFolder := VUAid('findfolder',{'amnu'}) + ":";
  245.     theCPAlias := controlPanelsFolder + "{name} alias";
  246.     theAMIAlias := appleMenuItemsFolder + "{name} alias";
  247.     
  248.     if VUAid('iconlocation', {theAMIAlias})        # delete existing alias from Apple Menu Items
  249.         VUAid('delete', {theAMIAlias});
  250.     if VUAid('iconlocation', {theCPAlias})        # and Control Panels folders if needed
  251.         VUAid('delete', {theCPAlias});
  252.     
  253.     if not open_control_panel()
  254.         return false;
  255.  
  256.     type_keys({name});
  257.     select_menuItem('Make Alias',2,,true,6);
  258.  
  259.     key_eq('i');
  260.     if not await_presence([window o:1 t:/{name} alias≈/])
  261.     begin
  262.         key_eq("ww",,v_level);
  263.         return RIncomplete("alias_control_panel: Problem making an alias to control panel: {name}", v_level);
  264.     end;
  265.     key_eq('ww',,v_level);
  266.  
  267.     if not VUAid('move',{theCPAlias,appleMenuItemsFolder})
  268.         return RIncomplete("alias_control_panel: Problem moving the alias to the Apple menu", v_level);
  269.     
  270.     ### Everything worked - double check
  271.     if not await_presence([menuItem t:"{name} alias" m:1],,,,6)     #verify the alias in the Apple menu
  272.         return RIncomplete("alias_control_panel: The alias did not appear in the Apple menu", v_level);
  273.     return true;
  274. end;
  275.  
  276.  
  277. #########################################################################
  278. #    task                    key_repeat_off(v_level)
  279. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  280. #    Description:    Turns off Keyboard repeat rate in Keyboard CDEV. This task was 
  281. #                    created for certain CPUs with faulty network hardware. The  
  282. #                    fault occurred when VU was telling Agent VU to press and release a 
  283. #                    key, leaving the key pressed for seconds or more at a time. 
  284. #                    The character repeated when a single instance was specified.
  285. #    Parameters:        v_level:        verbosity level for log output
  286. #    Returns:        true
  287. #    Examples:        key_repeat_off();
  288. #    Assumptions:    None
  289. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  290. #    History:
  291. #        07/14/92    JDM        Incorporated into Clouseau.Lib. 
  292. #        02/19/94    SBR        Added check for 0 in low-memory system global keyThresh 
  293. #                            (address 398, or 0x18E) to save time.
  294. #########################################################################
  295. task    key_repeat_off(v_level := 5)
  296. begin
  297.     ### Remove lines below if keyThresh (398) becomes unavailable or if you get bored
  298.     keyRepeat := VUAid('GetMemory', {'byte','398'});    #7F = Off, 0 = On
  299.     VUAid('Quit');
  300.     keyRepeat := strToNum( keyRepeat );    #7F = Off, 0 = On
  301.     if keyRepeat
  302.         return true;    #7F = Off, 0 = On
  303.     ### Remove lines above if keyThresh (398) becomes unavailable
  304.  
  305.     if not open_control_panel("Keyboard")
  306.         return RIncomplete("key_repeat_off: Unable to open keyboard CDEV");
  307.     move_mouse({{140,50}, 'click'});
  308.     key_eq("w");
  309.     return true;
  310. end;
  311.  
  312.  
  313. #########################################################################
  314. #    task                reset_target_info(v_level)
  315. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  316. #    Description:    logs and stores information about the target for later use
  317. #    Parameters:        pSystemFiles:    true:    print System files and their versions
  318. #                                    false:    do not print System files
  319. #                    NOTE: Using v_level instead of pSystemFiles to regulate printing.
  320. #                    pSystemFiles does nothing. Leaving in for compatibility.
  321. #                    v_level:        the verbosity level
  322. #    Returns:        nothing
  323. #    Examples:        reset_target_info(, 2);
  324. #    Assumptions:    VU 2.1, All external tools exist, versions are correct, 
  325. #                    target Program Linking is on with Guest Access
  326. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  327. #    History:
  328. #        03/15/93    SBR        Created
  329. #        05/27/93    SBR        changed g_Target_Info_ to an associate list
  330. #        05/27/93    SBR        fixed a bug in the build version formatting
  331. #        05/28/93    SBR        added items for New Heap type
  332. #        06/01/93    SBR        changed task name to reset_target_info
  333. #        09/03/94    SBR        Added error handling for target access
  334. #        09/10/94    SBR        Added OnTarget access; converted to long integers
  335. #                            VU 2.1 Gestalt returns long integers, made changes for this.
  336. #        03/26/95    SBR        Added Long Word at Zero (check for EvenBetterBusError)
  337. #        07/12/95    SBR        Added pSystemFiles parameter
  338. #        08/01/95    SBR        Added store target info for Radar 1275886
  339. #        06/01/96    MSO        Documented pSystemFiles parameter for Radar 1294574
  340. #        08/27/96    BRL        Removed OnTarget calls/FileTool version checking
  341. #        09/27/96    BRL/MSO    Added SPEC exception handling
  342. #########################################################################
  343. task    reset_target_info(pSystemFiles := false, v_level:= 2)
  344. begin
  345.     global g_Target_Info_;
  346. (*
  347.     g_Target_Info_ is an associate list, which means we can add, remove or change an
  348.     item without worrying about things like its ordinal in the list, or its global 
  349.     declaration in tasks. A few of the things are available from Gestalt directly 
  350.     or indirectly, most require special methods which are undesirable to use in 
  351.     some situations. Most importantly this information is available even when the 
  352.     target has failed.
  353.     
  354.     g_Target_Info_ = 
  355.         {                                        TYPE        DESCRIPTION    
  356.             { 'name',tName },                    string        target name
  357.             { 'zone',tZone },                    string        target zone
  358.             { 'machine',machStr },                string        machine type (formatted)
  359.             { 'machine#',machValue },            integer        machine type (raw from Gestalt)
  360.             { 'processor',procStr },            string        processor type (formatted)
  361.             { 'processor#',procValue },            integer        processor type (raw from Gestalt)
  362.             { 'fpu',fpuStr },                    string        floating point unit type (formatted)
  363.             { 'fpu#',fpuValue },                integer        floating point unit type (raw from Gestalt)
  364.             { 'system',sysVersion },            string        system version (from match)
  365.             { 'rom family',romFStr },            string        ROM family (formatted)    
  366.             { 'rom family#',romFValue },        integer        ROM family (raw short)
  367.             { 'rom version',romVStr },            string        ROM build version (formatted)
  368.             { 'rom version#',romVValue },        integer        ROM build version (raw long)
  369.             { 'rom checksum',romCStr },            string        ROM checksum (formatted to Hex)
  370.             { 'rom checksum#',romCValue },        string        ROM checksum (raw long string)
  371.             { 'ram physical',ramPStr },            string        RAM physical (formatted)
  372.             { 'ram physical#',ramPValue },        list        RAM physical (raw from Gestalt)
  373.             { 'ram logical',ramLStr },            string        RAM logical (formatted)
  374.             { 'ram logical',ramLValue },        list        RAM logical (raw from Gestalt)
  375.             { 'vm',vmStr },                        string        'xM', 'Off', or 'Not available' (no MMU)
  376.             { 'vm#',vmFlag },                    Boolean        True, False, or Undefined (no MMU)
  377.             { '32',addr32Str },                    string        'On', 'Off', or 'Not available' (24-Bit only)
  378.             { '32#',addr32Flag },                Boolean        True, False, or Undefined (24-Bit only)
  379.             { 'screen setting','8-Bit Color' },    string        e.g. '8-Bit Color' (formatted)
  380.             { 'bit depth#',depthMode },            integer        bit depth (raw short)
  381.             { 'color#',colorFlag },                Boolean        True, False; undefined for B/W only
  382.             { '68040CacheCP',cache040Str },        string        'On', 'Off' or 'not a 68040'
  383.             { '68040CacheCP#',cache040Flag },    Boolean        True, False; undefined for not a 68040
  384.             { 'heapTypeStr',heapTypeStr },        string        'Pre-Modern 24-bit', 'Pre-Modern 24-bit', 
  385.                                                             'Modern 32-bit' or 'Modern 32-bit (debugging)'
  386.             { 'heapType#',heapType }            integer        heap type (non-zero for 32 bit memory managers)
  387.             { 'QuickTime version',qTimeStr },    string        QuickTime version (formatted)
  388.             { 'QuickTime version#',qTimeValue }    integer        QuickTime version (raw from Gestalt)
  389.             { 'startupVolume',startupVolume }    string        startup volume on the target
  390.             { 'system folder',systemFolder }    string        full pathname of active system folder on the target
  391.             { 'NIL value',nilStr }                string        long at zero to check writes to NIL (formatted to Hex)
  392.             { 'NIL value#',nilValue }            integer        long at zero to check writes to NIL (raw long)
  393. ###                extensions & controlpanels unused, see comments in reset_target_info()
  394. #                { 'extensions',sysExtList }            list        list of target extensions (see OnTarget('vers')
  395. #                { 'control panels',cpList }            list        list of target control panels (see OnTarget('vers')
  396.             { 'MacsBugLogName',mbLogName }        string        name of MacsBug logs when they are created
  397. #                { 'MemCP VM',{vmMode, vmFlag},        vmMode is a list: { sizeString, bsVolString }
  398. #                { 'MemCP 32',{addr32Mode, addr32Flag}},
  399. #                { 'MemCP RD',{rdMode, rdValue}},
  400. #                { 'MemCP DC',{dcMode, dcValue }}
  401.         };
  402. *)
  403.     
  404.     RStatus("Starting reading target configuration at {time_str(match [time],'h')}",2);
  405.     
  406.     temp := _Match([target]);
  407.     tName := temp.t;
  408.     tZone := temp.z;
  409.     targetASID := {"machine {tName} of zone {tZone}"};
  410.     
  411.     # Store target info added for Radar 1275886
  412.     storeTargetInfo := _MatchBoolean([actor t:"LQAssist"], true);
  413.     if storeTargetInfo and isUndefined(g_Target_Info_)
  414.     begin
  415.         # Try to restore the info instead of gathering it again
  416.         InitMessages();
  417.         tMsg := SendMessage( {'LQAssist'}, targetASID, {'restore'}, true, 10 );
  418.         if tMsg[1]
  419.         begin
  420.             println "reset_target_info: error requesting target info restore: {tMsg}";
  421.             tMsg := false;
  422.         end;
  423.         else
  424.         begin
  425.             tMsg := true;
  426.         end;
  427.         
  428.         if tMsg
  429.         begin
  430.             g_Target_Info_ := ReceiveMessage( targetASID, {'LQAssist'}, false, true, 10 );
  431.             if g_Target_Info_[1]
  432.             begin
  433.                 println "reset_target_info: error receiving Target Info: {g_Target_Info_}";
  434.                 g_Target_Info_ := undefined;
  435.             end;
  436.             else
  437.             begin
  438.                 g_Target_Info_ := g_Target_Info_[2];
  439.                 if not g_Target_Info_
  440.                 begin
  441.                     storeTargetInfo := true;
  442.                     g_Target_Info_ := undefined;
  443.                 end;
  444.                 else
  445.                 begin
  446.                     storeTargetInfo := false;            # no need to store it again
  447.                 end;
  448.             end;
  449.         end;
  450.     end;
  451.     else
  452.     begin
  453.         g_Target_Info_ := undefined;
  454.     end;
  455.     
  456.     if isUndefined( g_Target_Info_ )
  457.     begin
  458.         # If there is no stored target information, we have to gather it all again.
  459.         # This process takes about a minute, instead of a few seconds if stored.
  460.     
  461.         # Launch all external tools at the beginning
  462.         VUAid ('initialize', true);
  463.         VUAid('ReturnLongInts', true);
  464.         #OnTarget('initialize',true);   #9608.23 SBR Hacked out
  465.         FileTool('initialize',true); 
  466.         
  467.         temp := _Match([target]);
  468.         tName := temp.t;
  469.         tZone := temp.z;
  470.  
  471.         machList := target_machine();
  472.         procList := target_processor();
  473.         fpuList := target_fpu();
  474.     
  475.         temp := _Match([system]);
  476.         sysVersion := temp.v;
  477.     
  478.         g_Target_Info_ := {    { 'name',tName }, 
  479.                             { 'zone',tZone }, 
  480.                             { 'machine',machList[1] },
  481.                             { 'machine#',machList[2] },
  482.                             { 'processor',procList[1] },
  483.                             { 'processor#',procList[2] },
  484.                             { 'fpu',fpuList[1] },
  485.                             { 'fpu#',fpuList[2] },
  486.                             { 'system',sysVersion }
  487.                         };
  488.             
  489.         romBase := VUAid('GetMemory', {'long', 686});        #get the ROM base address
  490.         
  491.                                                             #get ROM version word
  492.         romFValue := VUAid('GetMemory', {'short', romBase + 8});
  493.         romFStr := midstr(numToStr(romFValue,16), 3, 4);    #drop the '0x'
  494.     
  495.                                                             #get ROM build word
  496.         romVValue := VUAid('GetMemory', {'short', romBase + 18});
  497.         romVStr := midstr(numToStr(romVValue,16), 3, 4);     #drop the '0x'
  498.         if romVStr[1] ~= /[0-9]/
  499.             dot := '.';            #e.g. 2.1A2 (0x21A2)
  500.         else dot := '';            #e.g. D11C4 (0xDBC4)
  501.         romVStrLen := card romVStr;
  502.         for i := 1 to 4 - romVStrLen                        #pad to 4 hex digits
  503.             romVStr := '0' + romVStr;
  504.         romVStr := "{romVStr[1]}{dot}{strToNum('0x' + romVStr[2])}" + 
  505.                     "{romVStr[3]}{strToNum('0x' + romVStr[4])}";
  506.     
  507.                                                             #get ROM checksum at ROMBase
  508.         romCValue := VUAid('GetMemory', {'long', romBase});
  509.         romCStr := midstr(numToStr(romCValue,16), 3, 8);     #drop the '0x'
  510.         g_Target_Info_ := g_Target_Info_ + {
  511.             { 'rom family',romFStr },
  512.             { 'rom family#',romFValue },
  513.             { 'rom version',romVStr },
  514.             { 'rom version#',romVValue },
  515.             { 'rom checksum',romCStr },
  516.             { 'rom checksum#',romCValue }
  517.         };
  518.         
  519.         ramPValue := _Gestalt('ram ')[2];                # Physical RAM in bytes
  520.         wholeMB := ramPValue / 1048576;
  521.         fractMB := ((ramPValue - (wholeMB * 1048576)) * 10) / 1048576;
  522.         ramPStr := "{numToStr(wholeMB)}.{fractMB}";        # String value in megabytes
  523.         
  524.         ramLValue := _Gestalt('lram')[2];                # Logical RAM in bytes
  525.         wholeMB := ramLValue / 1048576;
  526.         fractMB := ((ramLValue - (wholeMB * 1048576)) * 10) / 1048576;
  527.         ramLStr := "{numToStr(wholeMB)}.{fractMB}";        # String value in megabytes
  528.         g_Target_Info_ := g_Target_Info_ + {
  529.             { 'ram physical',ramPStr },
  530.             { 'ram physical#',ramPValue },
  531.             { 'ram logical',ramLStr },
  532.             { 'ram logical#',ramLValue }
  533.         };
  534.     
  535.         temp := _Gestalt('mmu ')[2];
  536.         if temp = 0 begin
  537.             vmFlag := undefined;
  538.             vmStr := 'Not Available';
  539.         end;
  540.         
  541.         else if _Gestalt('vm  ')[2] = 1 begin
  542.             vmFlag := true;
  543.             vmStr := 'On';
  544.         end;
  545.         else begin
  546.             vmFlag := false;
  547.             vmStr := 'Off';
  548.         end;
  549.         g_Target_Info_ := g_Target_Info_ + {{ 'VM',vmStr },{ 'VM#',vmFlag }};
  550.     
  551.         temp := _Gestalt('addr')[2];
  552.         if temp = 0 begin
  553.             addr32Flag := undefined;
  554.             addr32Str := 'Not Available';
  555.         end;
  556.         else if temp = 7 begin
  557.             addr32Flag := true;
  558.             addr32Str := 'On';
  559.         end;
  560.         else begin
  561.             addr32Flag := false;
  562.             addr32Str := 'Off';
  563.         end;
  564.         g_Target_Info_ := g_Target_Info_ + {{ '32',addr32Str },{ '32#',addr32Flag }};
  565.     
  566.         depthMode := VUAid('GetDepth');
  567.         g_Target_Info_ := g_Target_Info_ + {{ 'bit depth',depthMode }};
  568.     
  569.         if VUAid('GetGray') begin
  570.             if depthMode > 1 begin
  571.                 colorFlag := false;
  572.                 colorStr := 'Gray';
  573.             end;
  574.             else begin
  575.                 colorFlag := undefined;
  576.                 colorStr := 'Black and White';
  577.             end;
  578.         end;
  579.         else begin
  580.             colorFlag := true;
  581.             colorStr := 'Color';
  582.         end;
  583.         g_Target_Info_ := g_Target_Info_ + { { 'screen setting',"{depthMode}-bit {colorStr}" },
  584.             { 'bit depth#',depthMode },{ 'color#',colorFlag }
  585.         };
  586.         
  587.         temp := CacheSwitchCP();
  588.         if isUndefined(temp) begin
  589.             cache040Flag := undefined;
  590.             cache040Str := 'Target processor is not a 68040';
  591.         end;
  592.         else if temp begin
  593.             cache040Flag := true;
  594.             cache040Str := 'On';
  595.         end;
  596.         else begin
  597.             cache040Flag := false;
  598.             cache040Str := 'Off';
  599.         end;
  600.             g_Target_Info_ := g_Target_Info_ + {{ '68040CacheCP',cache040Str },
  601.                                                 { '68040CacheCP#',cache040Flag }};
  602.         
  603.                                                 #examine the system heap type to check Memory Manager version
  604.                                                 #this byte is offset 0x1E from the base of the system heap
  605.         heapType := VUAid('GetMemory', {'byte', VUAid('GetMemory', {'long', 678}) + 30});
  606.         heapTypeStr := assoc(heapType,
  607.             {
  608.              { 0, 'Pre-Modern 24-bit' },
  609.              { 1, 'Pre-Modern 32-bit' },
  610.              { 3, 'Modern 32-bit' },
  611.              { 7, 'Modern 32-bit (debugging)' }
  612.             }
  613.         );
  614.         if isUndefined(heapTypeStr)
  615.             heapTypeStr := "Unknown ({heapType})";
  616.         g_Target_Info_ := g_Target_Info_ + {{ 'heapTypeStr',heapTypeStr },
  617.                                             { 'heapType#',heapType }};
  618.     
  619.         temp := _Gestalt('qtim');            #get the QuickTime version
  620.         #    e.g. _Gestalt('qtim') returns { -5551, 28016 } -> not installed 
  621.         #    e.g. _Gestalt('qtim') returns { 0, 23232512 } -> 0x01628000 -> version 1.6.2
  622.         #    e.g. _Gestalt('qtim') returns { 0, 33587200 } -> 0x02008000 -> version 2.0.0
  623.         if not temp[1]
  624.         begin
  625.             quickTimeValue := temp[2];
  626.             quickTimeStr := midstr(numToStr(quickTimeValue,16), 3, 8);    #convert to hex, drop the '0x'
  627.             quickTimeStrLen := card quickTimeStr;
  628.             for i := 1 to 8 - quickTimeStrLen                            #pad to 8 hex digits
  629.                 quickTimeStr := '0' + quickTimeStr;
  630.                 
  631.             #use strToNum to remove leading zero
  632.             quickTimeStr := "Version {strToNum(quickTimeStr[1] + quickTimeStr[2])}." + 
  633.                 quickTimeStr[3] + quickTimeStr[4];
  634.         end;
  635.         else if temp[1] = -5551 begin
  636.             quickTimeValue := undefined;
  637.             quickTimeStr := 'Not Installed';
  638.         end;
  639.             g_Target_Info_ := g_Target_Info_ + {{ 'QuickTimeStr',quickTimeStr },
  640.                                                 { 'QuickTime#',quickTimeValue }};
  641.     
  642. #            'boot'        Name of boot volume    (only for VUAid 2.x)
  643. #            'amnu'        Apple Menu Items folder    
  644. #            'ctrl'        Control Panels folder    
  645. #            'desk'        Desktop folder    
  646. #            'extn'        Extensions folder    
  647. #            'pref'        Preferences folder    
  648. #            'prnt'        PrintMonitor Documents folder    
  649. #            'empt'        Shared, network Trash folder    
  650. #            'trsh'        Single-user trash folder    
  651. #            'strt'        Startup Items folder    
  652. #            'macs'        current System Folder    
  653. #            'temp'        Temporary Items folder
  654.  
  655.         g_Target_Info_ := g_Target_Info_ + {{ 'StartupVolume',VUAid("FindFolder", {'boot'}) },
  656.                                             { 'SystemFolder',VUAid("FindFolder", {'macs'}) }};
  657.                                                     
  658.         ###    can not use OnTarget to gather extension versions: only returns 50 items max
  659.         ###    current system folders have almost 80
  660.         #theExts := OnTarget("vers",'system','extn')[2];  #9608.23 SBR Hacked out
  661.         theExts := {};
  662.         theExtsLen := card theExts;
  663.         for i := 1 to theExtsLen
  664.         begin
  665.             thisExt := theExts[i];
  666.             theExts[i] := {thisExt[1], {thisExt[2],thisExt[3]}};
  667.         end;
  668.     
  669.         #theCPs := OnTarget("vers",'system','ctrl')[2];  #9608.23 SBR Hacked out
  670.         theCPs := {};
  671.         theCPsLen := card theCPs;
  672.         for i := 1 to theCPsLen
  673.         begin
  674.             thisCP := theCPs[i];
  675.             theCPs[i] := {thisCP[1], {thisCP[2],thisCP[3]}};
  676.         end;
  677.     
  678.         g_Target_Info_ := g_Target_Info_ + {    { 'Extensions',theExts },
  679.                                                 { 'ControlPanels',theCPs }};
  680.     
  681.         # name of new MacsBug logs when they are created
  682.         g_Target_Info_ := g_Target_Info_ + {{ 'MacsBugLogName','LQCrashLog' }};
  683.         
  684.         # make a new folder for MacsBug logs when they are created
  685.         startupVolume := get_target_info('startupVolume');
  686.         mbLogPath := "{startupVolume}:MacsBug Logs (new)";
  687.         if not FileExists("{mbLogPath}")[2]
  688.             CreateFolder("{mbLogPath}");
  689.     
  690.         g_Target_Info_ := g_Target_Info_ + {{ 'MacsBugLogPath', mbLogPath }};
  691.  
  692.         # Get the long at zero (NIL pointer) to check writes to NIL and if EBBE is installed.
  693.         # Usually the long at zero is set to 64K above the ROM base.
  694.         # EvenBetterBusError sets it to 50FF8001 hex.
  695.         nilValue := VUAid('GetMemory', {'long', 0});        #get the long word at zero
  696.         nilStr := midstr(numToStr(nilValue,16), 3, 8);         #drop the '0x'
  697.     
  698.         EBBEState := false;
  699.         switch nilValue
  700.         begin
  701.             case romBase + 0x10000:
  702.                 nilStr := nilStr + ' (standard value)';
  703.     
  704.             case 0x50FF8001:
  705.             begin
  706.                 nilStr := nilStr + ' (EvenBetterBusError is installed)';
  707.                 EBBEState := true;
  708.             end;
  709.             
  710.             default:
  711.                 nilStr := nilStr + ' (unknown value)';
  712.         end;
  713.         g_Target_Info_ := g_Target_Info_ + {{ 'NIL value',nilStr }, 
  714.                                             { 'NIL value#',nilValue }, 
  715.                                             {'EBBE', EBBEState}};
  716.     
  717.         SetUpGeneralControls();    # turn off shutdown warning, set app's folder to default
  718.         
  719.         memoryCPInfo := MemoryCP('readOnly');
  720.         if memoryCPInfo[1]
  721.             RIncomplete('Could not read the Memory control panel, exiting script.');
  722.         else 
  723.             memoryCPInfo := memoryCPInfo[4];
  724.             
  725.         memCPDC := assoc('dc', memoryCPInfo);
  726.         memCP32 := assoc('32', memoryCPInfo);
  727.         memCPMM := assoc('mm', memoryCPInfo);
  728.         memCPVM := assoc('vm', memoryCPInfo);
  729.         memCPRD := assoc('rd', memoryCPInfo);
  730.         
  731.         g_Target_Info_ := g_Target_Info_ + {{ 'memCPDC',memCPDC },{ 'memCP32',memCP32 },
  732.                                             { 'memCPMM',memCPMM },{ 'memCPVM',memCPVM },
  733.                                             { 'memCPRD',memCPRD }};
  734.         
  735.         # Quit all external tools at the end
  736.         FileTool('quit'); 
  737.         # OnTarget('quit');  #9608.23 SBR Hacked out
  738.         VUAid ('quit');
  739.         
  740.     end;        #if isUndefined( g_Target_Info_ )
  741.     RStatus("Stopped reading target configuration at {time_str(match [time],'h')}",2);
  742.  
  743.     theSeed := randomSeed();
  744.     
  745.     if R_BeVerbose(v_level)            # skip entirely to save time if not needed
  746.     begin
  747.         RStatus("TARGET INFORMATION •••••••••••••••••••••••••••••••••••••••••••••", v_level);
  748.         RStatus("    Target Name: '{assoc('name',g_Target_Info_)}'", v_level);
  749.         if assoc('zone',g_Target_Info_) <> '*'
  750.             RStatus("    Target Zone: '{assoc('zone',g_Target_Info_)}'", v_level);
  751.         RStatus("    Machine Type: " + assoc('machine',g_Target_Info_), v_level);
  752.         RStatus("    Processor Type: " + assoc('processor',g_Target_Info_), v_level);
  753.         RStatus("    FPU Type: " + assoc('fpu',g_Target_Info_), v_level);
  754.         RStatus("    ROM Family: {assoc('rom family',g_Target_Info_)}",v_level);
  755.         RStatus("    ROM Version: {assoc('rom version',g_Target_Info_)}",v_level);
  756.         RStatus("    ROM CheckSum: {assoc('rom checksum',g_Target_Info_)}",v_level);
  757.         RStatus("    System Version: {assoc('system',g_Target_Info_)}",v_level);
  758. #        RStatus("    Enabler Version: ????",v_level);
  759.         RStatus("    Physical RAM: {assoc('ram physical',g_Target_Info_)}", v_level);
  760.         if assoc('VM#',g_Target_Info_)
  761.             RStatus("    Logical RAM: {assoc('ram logical',g_Target_Info_)} (Virtual Memory + RAM Disk)", v_level);
  762.         else 
  763.             RStatus("    Logical RAM: {assoc('ram logical',g_Target_Info_)} (Physical RAM - RAM Disk - odd bits)", v_level);
  764.         RStatus("    Virtual Memory: {assoc('VM',g_Target_Info_)}", v_level);
  765.         RStatus("    32-Bit Addressing: {assoc('32',g_Target_Info_)}", v_level);
  766.         RStatus("    System Heap Type: {assoc('heapTypeStr',g_Target_Info_)}", v_level);                
  767.         RStatus("    QuickTime: {assoc('QuickTimeStr',g_Target_Info_)}", v_level);                
  768.         if not isUndefined(assoc('68040CacheCP#',g_Target_Info_))
  769.             RStatus("    68040 Caches: {assoc('68040CacheCP',g_Target_Info_)}", v_level);                
  770.         RStatus("    Screen Depth: {assoc('screen setting',g_Target_Info_)}", v_level);                
  771.         RStatus("    Random Seed: {theSeed}", v_level);                
  772.         RStatus("∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞", v_level);
  773.         RStatus("    Memory Control Panel:", v_level);
  774.         if assoc('memCPDC',g_Target_Info_)
  775.             RStatus("        Disk Cache: {assoc('memCPDC',g_Target_Info_)}", v_level);
  776.         if assoc('memCP32',g_Target_Info_)
  777.             RStatus("        32-Bit Addressing: {assoc('memCP32',g_Target_Info_)}", v_level);
  778.         if assoc('memCPMM',g_Target_Info_)
  779.             RStatus("        Modern Memory Manager: {assoc('memCPMM',g_Target_Info_)}", v_level);
  780.         if assoc('memCPVM',g_Target_Info_)
  781.             RStatus("        Virtual Memory: {assoc('memCPVM',g_Target_Info_)}", v_level);
  782.         if assoc('memCPRD',g_Target_Info_)
  783.             RStatus("        RAM Disk: {assoc('memCPRD',g_Target_Info_)}", v_level);
  784.         RStatus("∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞", v_level);
  785.         RStatus("    Control Panels:", v_level);
  786.         for each tFile in assoc('ControlPanels',g_Target_Info_)
  787.             RStatus("        {tFile}", v_level);
  788.         RStatus("∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞", v_level);
  789.         RStatus("    Extensions:", v_level);
  790.         for each tFile in assoc('Extensions',g_Target_Info_)
  791.             RStatus("        {tFile}", v_level);
  792.         RStatus("∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞", v_level);
  793.         RStatus("    Long word at NIL: {assoc('NIL value',g_Target_Info_)}",v_level);
  794.         RStatus("••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••", v_level);
  795.     end;
  796.  
  797.     # Store target info added for Radar 1275886
  798.     if storeTargetInfo
  799.     begin
  800.         tMsg := SendMessage( {'LQAssist'}, targetASID, g_Target_Info_, false, 10 );
  801.         if tMsg[1]
  802.         begin
  803.             println "reset_target_info: error storing Target info: {tMsg}";
  804.             tMsg := undefined;
  805.         end;
  806.         else
  807.         begin
  808.             tMsg := tMsg[2];
  809.         end;
  810.     end;
  811. end;
  812.  
  813. #########################################################################
  814. #    task                target_machine(v_level)
  815. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  816. #    Description:    Returns the name and number of the machine type returned by Gestalt
  817. #
  818. #                    WARNING: includes unreleased machine names; APPLE INTERNAL USE ONLY
  819. #
  820. #    Parameters:        v_level
  821. #    Returns:        {machStr or 'unknown', machValue}
  822. #    Examples:        myMachineStr := target_machine()[1];
  823. #    Assumptions:    VU 2.0
  824. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  825. #    History:
  826. #        03/10/92    JDM        Creation (called target_cpu in VUAid)
  827. #        01/06/93    SBR        Rebuilt to use assoc and VU 2.0 Gestalt
  828. #        06/01/93    SBR        Renamed from target_CPU_LQ to target_machine_LQ
  829. #        02/19/94    SBR        Renamed from target_machine_LQ to target_machine
  830. #        09/13/94    SBR        VU 2.1 Gestalt returns long integers; made changes for this.
  831. #        08/09/95    SBR        Updated machine list for Radar 1275848.
  832. #        09/27/96    BRL/MSO    Added SPEC exception handling
  833. #########################################################################
  834. task    target_machine(v_level := 4)
  835. begin
  836.     machValue := _Gestalt('mach');
  837.     err := machValue[1];
  838.     if err begin
  839.         RIncomplete("target_machine: Gestalt('mach') returned error #{err}", v_level);
  840.         return {"unknown ({machValue})",-1};
  841.     end;
  842.     else machValue := machValue[2];
  843.     
  844.     machStr := assoc
  845.     (    machValue, 
  846.         {
  847.             {1, "128K, 512K"},
  848.             {2, "XL"},
  849.             {3, "512Ke"},
  850.             {4, "Plus"},
  851.             {5, "SE, SE FDHD"},
  852.             {6, "II"},
  853.             {7, "IIx"},
  854.             {8, "IIcx"},
  855.             {9, "SE/30"},
  856.             {10, "Portable"},
  857.             {11, "IIci"},
  858.             {13, "IIfx"},
  859.             {17, "Classic"},
  860.             {18, "IIsi"},
  861.             {19, "LC"},
  862.             {20, "Quadra 900"},
  863.             {21, "PowerBook 170"},
  864.             {22, "Quadra 700"},
  865.             {23, "Classic II, Performa 200"},
  866.             {24, "PowerBook 100"},
  867.             {25, "PowerBook 140"},
  868.             {26, "Quadra 950, WG Server 95"},
  869.             {27, "LC III, Performa 450"},
  870.             {29, "PowerBook Duo 210"},
  871.             {30, "Centris 650"},
  872.             {32, "PowerBook Duo 230"},
  873.             {33, "PowerBook 180"},
  874.             {34, "PowerBook 160"},
  875.             {35, "Quadra 800, WG Server 80"},
  876.             {36, "Quadra 650"},
  877.             {37, "LC II, Performa 400,405,410,430"},
  878.             {38, "PowerBook Duo 250"},
  879.             {39, "WG Server 9150"},
  880.             {40, "Power 8100/110, 8115/110, WG Server 8150/110"},
  881.             {41, "Power 5200/75 LC, Performa 5200,5210,5215,5220"},
  882.             {42, "Power 6200/75, Performa 6200,6216,6218,6220,6230"},
  883.                 {43, "Cyclone33•"},
  884.             {44, "IIvi"},
  885.             {45, "Performa 600"  (*IIvm•*)},
  886.             {47, "Power 7100/80, 7100/80AV"},
  887.             {48, "IIvx"},
  888.             {49, "Color Classic, Color Classic II, Performa 250,275"},
  889.             {50, "PowerBook 165c"},
  890.             {52, "Centris 610, WG Server 60, WG Server 60 (50/25 MHz)"},
  891.             {53, "Quadra 610, Quadra 610 DOS Compatible"},
  892.             {54, "PowerBook 145,145B"},
  893.             {55, "Power 8100/100, 8100/100AV"},
  894.             {56, "LC 520, Performa 520"},
  895.             {57, "WG Server 9150/120"},
  896.             {60, "Centris 660AV, Quadra 660AV"},
  897.                 {61, "Smurf700•"},
  898.             {62, "LC III+, Performa 460,466,467"},
  899.                 {64, "Power 8100/60•"},
  900.             {65, "Power 8100/80, 8100/80AV, WG Server 8150"},
  901.                 {66, "Power 8100/100•"},
  902.             {67, "Power 9500/120, 9500/132" (*"Power 9500/132"*)},
  903.             {68, "Power 7500/100"},
  904.             {69, "Power 8500/120"},
  905.             {71, "PowerBook 180c"},
  906.             {72, "PowerBook 520,520c,540,540c"},
  907.                 {74, "PDM Evt 1 (R.I.P.)•"},
  908.             {75, "Power 6100/60, 6100/60AV, Performa 6110,6112,6115,6116,6117,6118, WG Server 6150"},
  909.             {77, "PowerBook Duo 270c" (*"Escher•"*)},
  910.             {78, "Quadra 840AV"},
  911.                 {79, "Tempest33•"},
  912.             {80, "LC 550, Performa 550,560"},
  913.                 {82, "Smurf650•"},
  914.                 {83, "Slice33•"},
  915.             {84, "PowerBook 165"},
  916.                 {85, "PowerBook 165•"},
  917.                 {86, "Primus20•"},
  918.                 {87, "Optimus20•"},
  919.             {88, "Mac TV" (*"HookTV•"*)},
  920.             {89, "LC 475, Performa 475,476"},
  921.                 {90, "Primus33•"},
  922.                 {91, "Optimus25•"},
  923.             {92, "LC 575, Performa 575,577,578" (*"Optimus33•"*)},
  924.                 {93, "Aladdin20•"},
  925.             {94, "Quadra 605"},
  926.                 {95, "Aladdin33•"},
  927.             {98, "LC 630, LC 630 DOS Compatible, Quadra 630, Performa 630,631,635,636,637,638,640 DOS Compatible" (*"Color Classic 040 (25)•"*)},
  928.             {99, "LC 580, Performa 580,588" (*"Color Classic 040 (33)"*)},
  929.             {100, "Power 6100/66, 6100/66AV, 6100/66 DOS Compatible, WG Server 6150/66"},
  930.                 {101, "Power 6100/80•"},
  931.             {102, "PowerBook Duo 280"},
  932.             {103, "PowerBook Duo 280c"},
  933.             {104, "Power 475/605" (*"900 Smurf"*)},
  934.             {105, "Power 575" (*"950 Smurf"*)},
  935.             {106, "Power 630" (*"610 Smurf"*)},
  936.             {107, "Power 580" (*"800 Smurf"*)},
  937.             {108, "Power 7200/75" (*", 7200/90", "Q610 Smurf"*)},
  938.             {109, "Q650 Smurf•"},
  939.                 {111, "Power 7100/60•"},
  940.             {112, "Power 7100/66, 7100/66AV"},
  941.                 {113, "Power 7100/80•"},
  942.             {115, "PowerBook 150"},
  943.             {116, "Power 700"},
  944.             {117, "Power 900"},
  945.             {118, "Power 950"},
  946.             {119, "Power C610"},
  947.             {120, "Power C650"},
  948.             {121, "Power Q610"},
  949.             {122, "Power Q650"},
  950.             {123, "Power 800"}
  951.         }
  952.     );
  953.     if not machStr
  954.         machStr := "unknown ({machValue})";
  955.     return {machStr,machValue};                
  956. end;
  957.  
  958. #########################################################################
  959. #    task                target_processor(v_level)
  960. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  961. #    Description:    Returns the name and number of the main processor returned by Gestalt
  962. #    Parameters:        v_level
  963. #    Returns:        {procStr or 'unknown', procValue}
  964. #    Examples:        myProcessorName := target_processor()[1];
  965. #    Assumptions:    VU 2.0
  966. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  967. #    History:
  968. #        06/04/93    SBR                Created
  969. #        02/19/94    SBR                Renamed from target_processor_LQ to target_processor
  970. #        06/17/94    Gary Kratzer    Added PowerPC support
  971. #        09/13/94    SBR        VU 2.1 Gestalt returns long integers; made changes for this.
  972. #        09/23/94    SBR        Changed 680x0 values (added 1 to each) to match Gestalt.equ.
  973. #                            These values need verifying on 7.1 and 7.5
  974. #        09/18/95    SBR        Added 'PPC603e'.
  975. #                            Radar 1285671: Fix for unknown PowerPC processors.
  976. #        09/27/96    BRL/MSO    Added SPEC exception handling
  977. #########################################################################
  978. task    target_processor(v_level:=5)
  979. begin
  980.     PPCGestalt := true;
  981.     procValue := _Gestalt('cput');        # Try new improved CPU-type Gestalt call
  982.     if procValue[1] <> 0
  983.     begin
  984.         PPCGestalt := false;
  985.         procValue := _Gestalt('proc');    # If it's not there, revert to old fashioned method
  986.     end;
  987.  
  988.     err := procValue[1];
  989.     if err 
  990.     begin
  991.         RIncomplete("target_proc: Gestalt('proc') returned error #{err}", v_level);
  992.         return {"unknown ({procValue})",-1};
  993.     end;
  994.     else 
  995.         procValue := procValue[2];
  996.     
  997. #    RStatus("target_processor: PPCGestalt = {PPCGestalt}, procValue = {procValue}",2);
  998.     if PPCGestalt = true
  999.     begin
  1000.         procStr := assoc( procValue, 
  1001.             {
  1002. #    This set works on a Quadra 840AV, the other set is for System 7.5? Needs verifying on all CPUs
  1003. #                    {1,     '68000'},
  1004. #                    {2,     '68010'},
  1005. #                    {3,     '68020'},
  1006. #                    {4,     '68030'},
  1007. #                    {5,        '68040'},
  1008.                 {0,     '68000'},
  1009.                 {1,     '68010'},
  1010.                 {2,     '68020'},
  1011.                 {3,     '68030'},
  1012.                 {4,        '68040'},
  1013.                 {257,     'PPC601'},
  1014.                 {259,     'PPC603'},
  1015.                 {260,     'PPC604'},
  1016.                 {262,     'PPC603e'}
  1017.             });
  1018.         
  1019.         #Added for Radar 1285671
  1020.         if not procStr
  1021.             procStr := "PPC unknown ({procValue})";
  1022.     end;
  1023.     
  1024.     else 
  1025.     begin
  1026.         procStr := assoc( procValue, 
  1027.             {
  1028.                 {1, '68000'},
  1029.                 {2, '68010'},
  1030.                 {3, '68020'},
  1031.                 {4, '68030'},
  1032.                 {5, '68040'}
  1033.             });
  1034.  
  1035.         #Added for Radar 1285671
  1036.         if not procStr
  1037.             procStr := "68K unknown ({procValue})";
  1038.     end;
  1039.  
  1040.     return {procStr,procValue};                
  1041. end;
  1042.  
  1043.  
  1044. #########################################################################
  1045. #    task                target_fpu(v_level)
  1046. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1047. #    Description:    Returns the name and number of the math coprocessor returned by Gestalt
  1048. #    Parameters:        v_level
  1049. #    Returns:        {fpuStr or 'unknown', fpuValue}
  1050. #    Examples:        myFPUName := target_fpu()[1];
  1051. #    Assumptions:    VU 2.0
  1052. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1053. #    History:
  1054. #        05/24/93    SBR            Created
  1055. #        09/13/94    SBR            VU 2.1 Gestalt returns long integers; made changes for this.
  1056. #        09/27/96    BRL/MSO        Added SPEC exception handling
  1057. #########################################################################
  1058. task    target_fpu(v_level := 5)
  1059. begin
  1060.     fpuValue := _Gestalt('fpu ');
  1061.     err := fpuValue[1];
  1062.     if err begin
  1063.         RIncomplete("target_fpu: Gestalt('fpu ') returned error #{err}", v_level);
  1064.         return {'unknown',-1};
  1065.     end;
  1066.     else fpuValue := fpuValue[2];
  1067.     
  1068.     fpuStr := assoc( fpuValue, 
  1069.         {
  1070.             {0, 'no FPU'},
  1071.             {1, '68881'},
  1072.             {2, '68882'},
  1073.             {3, '68040 built-in'}
  1074.         }
  1075.     );
  1076.     if not fpuStr
  1077.         fpuStr := "unknown ({fpuValue})";
  1078.     return {fpuStr,fpuValue};                
  1079. end;
  1080.  
  1081.  
  1082. #########################################################################
  1083. #    task                get_target_info(infoType, v_level)
  1084. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1085. #    Description:    Retrieves stored target information (see reset_target_info)
  1086. #    Parameters:        infoType:    string or list of strings specifying what kind of
  1087. #                                information to look up
  1088. #                    v_level
  1089. #    Returns:        value or list of values corresponding to each member of infoType
  1090. #    Examples:        laMachine := get_target_info('machine');
  1091. #    Assumptions:    VU 2.0
  1092. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1093. #    History:
  1094. #        06/04/93    SBR        Created
  1095. #        09/03/94    SBR        Added warning for undefined
  1096. #########################################################################
  1097. task get_target_info(infoType := '', v_level := 4)
  1098. begin
  1099.     global g_Target_Info_;
  1100.     
  1101.     if isUndefined(g_Target_Info_)
  1102.     begin
  1103.         RError('Someone called get_target_info() without first calling reset_target_info()',1);
  1104.         return undefined;
  1105.     end;
  1106.     if typeOf(infoType) = 'string' 
  1107.     begin
  1108.         returnValue := assoc(infoType, g_Target_Info_);
  1109.         if RXStatus(v_level)        # RXStatus for possible too-large strings
  1110.             println "get_target_info: retrieved value of type '{infoType}' is ", returnValue;
  1111.     end;
  1112.     else 
  1113.     begin
  1114.         returnValue := {};
  1115.         for each iType in infoType 
  1116.         begin
  1117.             temp := assoc(infoType, g_Target_Info_);
  1118.             if RXStatus(v_level)        # RXStatus for possible too-large strings
  1119.                 println "get_target_info: retrieved value of type '{infoType}' is ", returnValue;
  1120.             returnValue := returnValue + {temp};
  1121.         end;
  1122.     end;
  1123.     return returnValue;
  1124. end;
  1125.  
  1126.  
  1127. ##############################################################################################
  1128. #        target_control( theMode, zeroMode, v_level)
  1129. #=============================================================================================
  1130. #    Author:            SBR
  1131. #    Description:    dispatches setup lists to other routines
  1132. #    Parameters:        theMode: an integer standing for a pre-defined Memory control panel setup
  1133. #                    zeroMode: a list of settings for mode 0 (custom)
  1134. #                    Clicking the Use Defaults button, {'ud','click'}, has these effects:
  1135. #                        The Disk Cache is set according to a formula
  1136. #                        If the RAM Disk is empty it is turned Off
  1137. #                        If the 32-Bit section is visible it is set to 24-Bit
  1138. #                        The VM backing store volume is set to the startup volume
  1139. #                        The VM amount is set to twice the available built-in RAM
  1140. #    Returns:        nothing 
  1141. #    Examples:        target_control(5);
  1142. #    Assumptions:    none
  1143. #=============================================================================================
  1144. #    History:
  1145. #        Date:        By:        Changes:
  1146. #        03/15/93    SBR        Created
  1147. ##############################################################################################
  1148. task    target_control
  1149. (
  1150.     theMode := 1,
  1151.     zeroMode := {
  1152.                     { 'dc','96K' },
  1153.                     { 'vm','Off'},
  1154.                     { '32','On'},
  1155.                     { 'rd','Off'},
  1156.                     { 'ud','click'},
  1157.                     'quick'
  1158.                 },
  1159.     v_level := 3
  1160. )
  1161. begin
  1162.     #RPushVerbosity(v_level);
  1163.     
  1164.     theModes := 
  1165.         {
  1166. #            Standard modes
  1167.             { 1, {    { 'vm',{ 'auto','' } },
  1168.                     { '32','On' },
  1169.                     { 'ud','click' },
  1170.                     'quick' } },
  1171.             { 2, {    { 'vm',{ 'Off','' } },
  1172.                     { '32','On' },
  1173.                     { 'ud','click' },
  1174.                     'quick' } },
  1175.             { 3, {    { 'vm',{ 'auto','' } },
  1176.                     { '32','Off' },
  1177.                     { 'ud','click' },
  1178.                     'quick' } },
  1179.             { 4, {    { 'vm',{ 'Off','' } },
  1180.                     { '32','Off' },
  1181.                     { 'ud','click' },
  1182.                     'quick' } },        
  1183.             { 5, {    { 'vm',{ 'random','' } },
  1184.                     { 'mm','random' },
  1185.                     { '32','random' },
  1186.                     { 'rd','random' },
  1187.                     { 'dc','random' },
  1188.                     { 'ud','click' },
  1189.                     'quick' } },
  1190.             { 6, {    { 'vm',{ 'auto','' } },
  1191.                     { '32','On' },
  1192.                     { 'rd','min' },
  1193.                     { 'ud','click' },
  1194.                     'quick' } },
  1195.             { 7, {    { 'vm',{ 'Off','' } },
  1196.                     { '32','On' },
  1197.                     { 'rd','max' },
  1198.                     { 'dc','max' },
  1199.                     { 'ud','click' },
  1200.                     'quick' } },
  1201.             { 8, {    { 'vm',{ 'max','' } },
  1202.                     { '32','On' },
  1203.                     { 'rd','max' },
  1204.                     { 'dc','max' },
  1205.                     { 'ud','click' },
  1206.                     'quick' } },
  1207. #                { 9, {    { 'vm',{ 'random','' } },            # mode 9 is undefined.
  1208. #                        { '32','random' },
  1209. #                        { 'rd','random' },
  1210. #                        { 'dc','random' },
  1211. #                        { 'ud','click' } } },
  1212.             { 0, zeroMode },
  1213.  
  1214.  
  1215. #            A la mode (takes up the last position so commas are not a worry
  1216.             {}
  1217.         };
  1218.         
  1219.     modeSet := theMode / 10;
  1220.     if modeSet = 0 begin                # 0-9 imply New Memory Manager On (Faster) on PowerPC
  1221.         mmList := {'mm','On'};
  1222.     end;
  1223.     if modeSet = 3 begin                # 30-39 are PowerPC with New Memory Manager Off (More Compatible)
  1224.         theMode := theMode - modeSet * 10;
  1225.         mmList := {'mm','Off'};
  1226.     end;
  1227.         
  1228.     theConfigList := assoc(theMode, theModes);
  1229.     
  1230.     if theConfigList
  1231.     begin
  1232.         if theMode <> 5
  1233.             theConfigList := theConfigList + {mmList};
  1234.         RStatus("target_control: Setting target to configuration {theMode}:",2);
  1235.         RStatus("    {theConfigList}",2);
  1236.         memoryCPResult := MemoryCP(theConfigList,2);
  1237.         restart_target(4);
  1238.         
  1239.         MacsBugLog('target_control restart');
  1240.         SetMacsBugMacro('restore',v_level);        
  1241.  
  1242.         reset_target_info(v_level);
  1243.         return true;
  1244.     end;
  1245.     else return RIncomplete("target_control: '{theMode}' is invalid input. Please use 0-8 or 30-38");
  1246. end;
  1247.  
  1248. #########################################################################
  1249. #    task            SelectPrinter(pType, pOptions, v_level)
  1250. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1251. #    Description:    Selects a printer by typing its name in the Chooser.
  1252. #                    Verifies by selecting Page Setup in the Finder and 
  1253. #                    checking statictext items in the dialog. 
  1254. #    Parameters:        pSelection:
  1255. #                        string type of printer to select (Chooser extension file) 
  1256. #                            (this is the old way to use this task)
  1257. #                        OR
  1258. #                        List of two items, comprising a printer description:
  1259. #                            [1]: string type of printer to select (Chooser extension file) 
  1260. #                            [2]: list of options for that kind of printer
  1261. #                        OR
  1262. #                        List of printer descriptions: Try each in order
  1263. #                            until one succeeds. Fail if the last one fails.
  1264. #                    v_level:    verbosity level for log output
  1265. #    Returns:        true if it was successfully opened
  1266. #                    false if an error occured while attempting to open it.  
  1267. #    Examples:        SelectPrinter('Laserwriter');
  1268. #                    SelectPrinter({'Laserwriter 8',{'name', 'Deep Space 10'}});
  1269. #                    SelectPrinter({'LaserWriter,{}},{'Laserwriter 8',{'name', 'Deep Space 10'}});
  1270. #    Assumptions:    1) Task get_target_info() can return a list of extensions to check if a 
  1271. #                    printer type exists. If get_target_info() does not have a list
  1272. #                    of extensions, then this task does not check if an RDEV is 
  1273. #                    available before trying to select it. It could select 
  1274. #                    something you do not want. You can not "unselect" in the Chooser.
  1275. #                    2) If you type a printer name, the lower level task verifies it
  1276. #                    3) Uses OnTarget 1.2.1 'vers' service format
  1277. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1278. #    History:
  1279. #        01/27/93    SBR        created
  1280. #        08/27/94    SBR        reformatted and commented
  1281. #        09/03/94    SBR        started moving to new printer select architecture
  1282. #        04/09/95    SBR        added support for GX printers
  1283. #        09/05/95    MSO        added SelectColorSW2400
  1284. #        06/01/96    MSO        uncommented SelectColorSW2400GX and SelectLaserWriterGX
  1285. #        08/23/96    SBR        Added special case if the Extensions list = {}
  1286. #        09/27/96    BRL/MSO    Added SPEC exception handling
  1287. #########################################################################
  1288. task SelectPrinter( pSelection := {'LaserWriter', {}}, v_level := 5)
  1289. begin
  1290.     try begin 
  1291.         # go to Finder
  1292.         previousApp := _Match([application]).t;
  1293.         if not twitch('Finder')
  1294.             throw "could not switch to the Finder.";
  1295.         
  1296.         pSelectionType := typeOf(pSelection);
  1297.         
  1298.         if pSelectionType = 'string'                    # to provide same behavior as old task
  1299.             pSelection := {{pSelection,{}}};
  1300.         else if (pSelectionType = 'list') 
  1301.         begin
  1302.             if (typeOf(pSelection[1]) = 'string')        # new format, single request
  1303.                 pSelection := {pSelection};
  1304.         end;
  1305.         else
  1306.             throw "bad parameter: pSelection = {pSelection}";
  1307.             
  1308.         gesResult := _Gestalt('pmgr');
  1309.         if (gesResult[1] = 0)        # if no error then GX print manager is installed
  1310.         begin
  1311.             printerDispatchTable :=
  1312.             {
  1313.                     # Quickdraw GX Printers
  1314.                     { 'Color SW 2400 GX',            task SelectColorSW2400GX },
  1315. #                        { 'ImageWriter GX',                task SelectImageWriterGX },
  1316. #                        { 'ImageWriter LQ GX',            task SelectImageWriterLQGX },
  1317.                     { 'LaserWriter GX',                task SelectLaserWriterGX },
  1318. #                        { 'LaserWriter IISC GX',        task SelectLaserWriterIISCGX },
  1319. #                        { 'LW 300/LS GX',                task SelectLW300LSGX },
  1320.                     { 'PDD Maker GX',                task SelectPDDMakerGX }
  1321. #                        { 'StyleWriter GX',                task SelectStyleWriterGX }
  1322.             };
  1323.         end;
  1324.         else        
  1325.         begin
  1326.             printerDispatchTable :=
  1327.             {
  1328.                     # Postscript and Classic Quickdraw Printers
  1329.                     { 'AppleTalk ImageWriter',        task SelectATImageWriter },
  1330.                     { 'ImageWriter',                task SelectImageWriter },
  1331.                     { 'LaserWriter',                task SelectLaserWriter },
  1332.                     { 'LaserWriter 300',            task SelectLaserWriter300 },
  1333.                     { 'LaserWriter 8',                task SelectLaserWriter8 },
  1334.                     { 'LW Select 310',                task SelectLWSelect310 },
  1335.                     { 'LQ AppleTalk ImageWriter',    task SelectLQATImageWriter },
  1336.                     { 'LQ ImageWriter',                task SelectLQImageWriter },
  1337.                     { 'Personal LaserWriter SC',    task SelectPersonalLaserWriterSC },
  1338.                     { 'Personal LW LS',                task SelectPersonalLWLS },
  1339.                     { 'StyleWriter',                task SelectStyleWriter },
  1340.                     { 'StyleWriter II',                task SelectStyleWriterII },
  1341.                     { 'Color SW 2400',                task SelectColorSW2400 }    # MSO 9/5/95 added
  1342.             };
  1343.         end;
  1344.         
  1345.         # by this time pSelection is a list of at least one printer description
  1346.         theExtensions := get_target_info('extensions');
  1347.         numExtensions := card theExtensions;
  1348.         
  1349.         for each printerDescription in pSelection
  1350.         begin
  1351.             try
  1352.             begin
  1353.                 # parse the printer description
  1354.                 printerType := printerDescription[1];
  1355.                 printerSettings := printerDescription[2];
  1356.                 
  1357.                 # if contents of extensions folder are unknown, assume printer exists
  1358.                 if isUndefined( theExtensions )  or (theExtensions = {})
  1359.                     throw true;
  1360.                 
  1361.                 # check if printer file is in Extensions folder
  1362.                 theExtensionSpecs := assoc(printerType, theExtensions);                    
  1363.                 if not theExtensionSpecs
  1364.                     throw false;                    # try the next selection
  1365.                 
  1366.                 # check version if specified
  1367.                 extVersion := assoc('version',printerSettings);
  1368.                 if extVersion
  1369.                 begin
  1370.                     if not (extVersion = theExtensionSpecs[2])
  1371.                         throw false;                # try the next selection
  1372.                     else
  1373.                         throw true;
  1374.                 end;
  1375.                 else
  1376.                     throw true;
  1377.             end;
  1378.             catch theLoopTerminator
  1379.             begin
  1380.                 if theLoopTerminator        # we found an existing printer type
  1381.                 begin
  1382.                     # printer file of correct version exists, try to select it
  1383.                     thePrinterTask := assoc(printerType, printerDispatchTable);
  1384.                     if thePrinterTask
  1385.                     begin
  1386.                         printerSelectResult := call (thePrinterTask, printerSettings);
  1387.                         
  1388.                         if printerSelectResult[1]
  1389.                             throw printerSelectResult;
  1390.                         else 
  1391.                         begin    
  1392.                             twitch(previousApp);
  1393.                             return true;
  1394.                         end;
  1395.                     end;
  1396.                     else
  1397.                     begin
  1398.                         # do not throw here, let the loop continue
  1399.                         #throw "no task exists to set printer type {printerType}";
  1400.                     end;
  1401.                 end;
  1402.             end;
  1403.         end;
  1404.         throw 'could not find any of the requested printers';
  1405.     end;
  1406.     catch thePrinterError
  1407.     begin
  1408.         RError("SelectPrinter: error: {thePrinterError}",1);
  1409.         SysBeep(); SysBeep(); SysBeep(); 
  1410.         twitch(previousApp);
  1411.     end;
  1412. end;
  1413.         
  1414. #########################################################################
  1415. #    task            SelectDesktopPrinter( pSelection, v_level )
  1416. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1417. #    Description:    Selects a desktop printer by typing its name on the desktop and makes
  1418. #                    it the default if it is not already. If more options are given, 
  1419. #                    ensures that the printer is the right type, zone, printer, etc.
  1420. #    Parameters:        pSelection:
  1421. #                        List of two required items in the Get Info window:
  1422. #                        [1]:    String name of printer file to select
  1423. #                        [2]:    List of optional Get Info description fields; 
  1424. #                                see VerifyGetInfo() task for details.
  1425. #                                (can be an empty list)
  1426. #                    v_level:    verbosity level for log output
  1427. #    Returns:        true if it was successfully selected and made default
  1428. #                    false if printer could not be found or could not be made default.  
  1429. #    Examples (capitalization counts when using Locate String):
  1430. #                    SelectDesktopPrinter({'PDD Maker GX'});
  1431. #    
  1432. #                    SelectDesktopPrinter({    'The LaserWriter',
  1433. #                                            {    { 'Kind', 'desktop printer'},
  1434. #                                                { 'Type', 'LaserWriter GX'},
  1435. #                                                { 'Printer', 'Black Box LW IINTX'} } });
  1436. #                            
  1437. #                    SelectDesktopPrinter({    'My Direct Printer',
  1438. #                                            {    { 'Type', 'StyleWriter GX'},
  1439. #                                                { 'Port', 'Modem Port'} } });
  1440. #                            
  1441. #                    SelectDesktopPrinter({    'Our Favorite PrintServer', 
  1442. #                                            {    { 'Kind', 'shared desktop printer'},
  1443. #                                                { 'Type', 'LaserWriter GX'},
  1444. #                                                { 'Zone', 'Mariani 3rd'},
  1445. #                                                { 'Server', 'PrintLab LWII NTX'} } });
  1446. #    Assumptions:    1)    Assumes that the printer(s) in question have already been created 
  1447. #                        on the desktop.  This task does not create a desktop printer.
  1448. #                    2)    Finder is in front and there are no Info windows in front.
  1449. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1450. #    History:
  1451. #        03/20/95    MDF        created
  1452. #        04/04/95    MDF        changed gestalt to check for 0 as the version instead of 65792.
  1453. #        04/09/95    SBR        modified to go to Desktop; also checks Get Info window fields 
  1454. #        09/27/96    BRL/MSO    Added SPEC exception handling
  1455. #########################################################################
  1456. task SelectDesktopPrinter( pSelection := {'LaserWriter GX',{}}, v_level := 5)
  1457. begin
  1458.     gesResult := _Gestalt('pmgr');
  1459.     if (gesResult[1] <> 0)        # if error then print manager is not installed correctly
  1460.     begin
  1461.         RError("Sorry, the GX print manager is not installed correctly.",v_level);
  1462.         return false;
  1463.     end;
  1464.     else
  1465.     try begin
  1466.         printerName := pSelection[1];
  1467.         getInfoDescription := pSelection[2];
  1468.         
  1469.         # go to Finder
  1470.         previousApp := _Match([application]).t;
  1471.         if not twitch('Finder')
  1472.         begin
  1473.             RError("Could not switch to the Finder.",v_level);
  1474.         end;
  1475.         
  1476.         # bring desktop window to front using short cut to select startup volume
  1477.         type_keys({'latch',commandKey,'latch',shiftKey,'latch',optionKey, upArrowKey});
  1478.  
  1479.         # type the name and verify the Get Info window contents
  1480.         if not VerifyGetInfo(printerName, getInfoDescription, true)
  1481.         begin
  1482.             RError("Could not find '{printerName}' or verify its Get Info window.",v_level);    
  1483.             throw false;
  1484.         end;
  1485.  
  1486.         # We selected it and the specified options are correct; check for Printing menu
  1487.         
  1488.         menuState := _Match([menuItem t:"Set Default Printer" m:'Printing'], true);
  1489.         if not menuState
  1490.         begin
  1491.             RError("Could not locate 'Set Default Printer' in the 'Printing' menu.",v_level);
  1492.             throw false;
  1493.         end;
  1494.         else if menuState.c = ''        # This printer is already the default.
  1495.         begin
  1496.             RStatus("The printer '{printerName}' is the default printer", v_level);
  1497.             throw true;
  1498.         end;
  1499.         else begin                        # This printer is not the default; make it so.
  1500.             select_menuItem("Set Default Printer","Printing");
  1501.             if not await_presence([menuItem t:"Set Default Printer" m:'Printing' c:''])
  1502.             begin
  1503.                 RError("'{printerName}' did not become the default printer.",v_level);
  1504.                 throw false;
  1505.             end;
  1506.             RStatus("Made '{printerName}' the default printer", v_level);
  1507.             throw true;
  1508.         end;
  1509.     end;
  1510.     
  1511.     catch theTerminator                    # Generic ending for this task
  1512.     begin
  1513.         #type_keys({escapeKey});            # De-select all items in the Finder
  1514.         twitch( previousApp );
  1515.         return theTerminator;
  1516.     end;
  1517. end;
  1518.  
  1519. (*task SelectDesktopPrinter( pSelection := {'LaserWriter GX'}, v_level := 2)
  1520. begin
  1521.     gesResult := _Gestalt('pmgr');
  1522.     if (gesResult[2] <> 0)        # if true then GX has been installed correctly
  1523.     begin
  1524.         printerType := pSelection[1];
  1525.         options := pSelection[2];
  1526.         if (options[1] = 'name')
  1527.             printerName := options[2];
  1528.             type_keys({printerName,'latch', commandKey, "i"});
  1529.             
  1530.             if not _MatchBoolean([window t:/{printerName} Info≈/ o:1], true)
  1531.             begin
  1532.                 key_eq('w',,v_level);
  1533.                 RError("Could not find the printer '{printerType}' with name '{printerName}' on the desktop.",v_level);
  1534.                 return false;
  1535.             end;
  1536.             key_eq('w',,v_level);
  1537.             
  1538.             menuState := _Match([menuItem t:"Set Default Printer" m:'Printing'], true);
  1539.             if not (menuState.c = '')        # if this printer is not the default, make it the default
  1540.             begin
  1541.                 select_menuItem("Set Default Printer","Printing");
  1542.                 type_keys({'down', escapeKey, 'up', escapeKey});
  1543.                 RStatus("Made '{printerName}' the default printer)", v_level);
  1544.             end;
  1545.             return true;
  1546.         begin
  1547.             RError("name parameter not specified correctly.",v_level);
  1548.             return false;
  1549.         end;
  1550.     end;
  1551.     else                            # else, return false
  1552.     begin
  1553.         RError("Sorry, GX is not installed correctly.",v_level);
  1554.         return false;
  1555.     end;
  1556. end;
  1557. *)
  1558.  
  1559. #########################################################################
  1560. #    task            SelectATImageWriter(pOptions, v_level)
  1561. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1562. #    Description:    Selects an AppleTalk ImageWriter by typing its name in the Chooser.
  1563. #                    Verifies by selecting Page Setup in the Finder and 
  1564. #                    checking staticText items in the dialog. 
  1565. #    Parameters:        pOptions:    list optional settings, e.g. name, setup paramters
  1566. #                    v_level:    verbosity level for log output
  1567. #    Returns:        { theErr, "theErrString" }
  1568. #    Examples:        SelectATImageWriter({{'name',"Plodder"}});
  1569. #                    SelectATImageWriter({});
  1570. #    Assumptions:    WARNING: This task does not check if an RDEV is 
  1571. #                    available before trying to select it. It could select 
  1572. #                    something you do not want. You can not "unselect".
  1573. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1574. #    History:
  1575. #        01/06/95    Tony Clancy        created
  1576. #        09/27/96    BRL/MSO            Added SPEC exception handling
  1577. #########################################################################
  1578. task SelectATImageWriter( pOptions, v_level := 5)
  1579. begin
  1580.     if not select_menuItem('Page Setup…', 'File')
  1581.         return RError("SelectATImageWriter: could not select Page Setup… from the Finder File menu", 1);
  1582.     await_presence([window s:dialog o:1],,,,6);
  1583.     
  1584.     if _MatchBoolean([staticText t:"AppleTalk ImageWriter" w:1], true)
  1585.     begin
  1586.         type_keys({returnKey});
  1587.         return RStatus("SelectATImageWriter: AppleTalk ImageWriter is already the current printer type.", v_level);
  1588.     end;
  1589.     else
  1590.     begin
  1591.         type_keys({returnKey});
  1592.         if not (select_menuItem('Chooser', 1) and await_presence ([window t:'Chooser' o:1],,,,6))
  1593.             return RError("SelectATImageWriter: Failed to open the Chooser.",v_level);
  1594.         saveSpeed := typeSpeed(50);
  1595.         type_keys({'AppleTalk ImageWriter', 'latch', commandkey, 'q'}, 5);
  1596.         if await_presence ([staticText t:/You have changed your current printer.≈/ o:3 
  1597.                                 w:[window o:1 s:dialog] ],5,,,6) 
  1598.             type_keys({returnKey});
  1599.         await_presence ([application t:'Finder'],,,,6);
  1600.         select_menuItem('Page Setup…', 'File');
  1601.         if await_presence([staticText t:"AppleTalk ImageWriter" w:1],5,,,6) 
  1602.             myResult := RStatus("SelectATImageWriter: Selected AppleTalk ImageWriter in the Chooser.", v_level);
  1603.         else
  1604.             myResult := RError("SelectATImageWriter: Failed to select AppleTalk ImageWriter in the Chooser.",1);
  1605.         type_keys({returnKey});
  1606.         if myResult
  1607.             return {0, myResult};
  1608.         else
  1609.             return {-1, myResult};
  1610.     end;
  1611. end;
  1612.  
  1613. #########################################################################
  1614. #    task            SelectImageWriter(pOptions, v_level)
  1615. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1616. #    Description:    Selects an ImageWriter by clicking on the modem port icon.*
  1617. #                    Verifies by selecting Page Setup in the Finder and 
  1618. #                    checking staticText items in the dialog. 
  1619. #    Parameters:        pOptions:    list optional settings, e.g. name, setup paramters
  1620. #                    v_level:    verbosity level for log output
  1621. #    Returns:        { theErr, "theErrString" }
  1622. #    Examples:        SelectImageWriter({});
  1623. #    Assumptions:    WARNING: This task does not check if an RDEV is 
  1624. #                    available before trying to select it. It could select 
  1625. #                    something you do not want. You can not "unselect".
  1626. #                    We can only use the modem port as if we are to use the 
  1627. #                    printer port then we'll have to turn off Appletalk.
  1628. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1629. #    History:
  1630. #        01/06/95    Tony Clancy        created
  1631. #        09/27/96    BRL/MSO            Added SPEC exception handling
  1632. #########################################################################
  1633. task SelectImageWriter( pOptions, v_level := 5)
  1634. begin
  1635.     if not select_menuItem('Page Setup…', 'File')
  1636.         return RError("SelectImageWriter: could not select Page Setup… from the Finder File menu", 1);
  1637.     await_presence([window s:dialog o:1],,,,6);
  1638.     
  1639.     if _MatchBoolean([staticText t:"ImageWriter" w:1], true)
  1640.     begin
  1641.         type_keys({returnKey});
  1642.         return RStatus("SelectImageWriter: ImageWriter is already the current printer type.", v_level);
  1643.     end;
  1644.     else
  1645.     begin
  1646.         type_keys({returnKey});
  1647.         if not (select_menuItem('Chooser', 1) and await_presence ([window t:'Chooser' o:1],,,,6))
  1648.             return RError("SelectImageWriter: Failed to open the Chooser.",v_level);
  1649.         saveSpeed := typeSpeed(50);
  1650.         type_keys({'ImageWriter'}, 5);
  1651.         move_mouse({{340, 180}, 'rtw', 'click'});
  1652.         type_keys({'latch', commandkey, 'q'}, 5);
  1653.         if await_presence ([staticText t:/You have changed your current printer.≈/ o:3 
  1654.                                 w:[window o:1 s:dialog] ],5,,,6) 
  1655.             type_keys({returnKey});
  1656.         await_presence ([application t:'Finder'],,,,6);
  1657.         select_menuItem('Page Setup…', 'File');
  1658.         if await_presence([staticText t:"ImageWriter" w:1],5,,,6) 
  1659.             myResult := RStatus("SelectImageWriter: Selected ImageWriter in the Chooser.", v_level);
  1660.         else
  1661.             myResult := RError("SelectImageWriter: Failed to select ImageWriter in the Chooser.",1);
  1662.         type_keys({returnKey});
  1663.         if myResult
  1664.             return {0, myResult};
  1665.         else
  1666.             return {-1, myResult};
  1667.     end;
  1668. end;
  1669.  
  1670. #########################################################################
  1671. #    task            SelectLaserWriter(pOptions, v_level)
  1672. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1673. #    Description:    Selects a LaserWriter by typing its name in the Chooser.
  1674. #                    Verifies by selecting Page Setup in the Finder and 
  1675. #                    checking staticText items in the dialog. 
  1676. #    Parameters:        pOptions:    list optional settings, e.g. name, setup paramters
  1677. #                    v_level:    verbosity level for log output
  1678. #    Returns:        { theErr, "theErrString" }
  1679. #    Examples:        SelectLaserWriter({{'name',"Plodder"}});
  1680. #    Examples:        SelectLaserWriter({});
  1681. #    Assumptions:    WARNING: This task does not check if an RDEV is 
  1682. #                    available before trying to select it. It could select 
  1683. #                    something you do not want. You can not "unselect".
  1684. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1685. #    History:
  1686. #        09/15/94    SBR        created
  1687. #        09/27/96    BRL/MSO    Added SPEC exception handling
  1688. #########################################################################
  1689. task SelectLaserWriter( pOptions, v_level := 5)
  1690. begin
  1691.     if not select_menuItem('Page Setup…', 'File')
  1692.         return RError("SelectLaserWriter: could not select Page Setup… from the Finder File menu", 1);
  1693.     await_presence([window s:dialog o:1],,,,6);
  1694.     
  1695.     if _MatchBoolean([staticText t:"LaserWriter Page Setup" w:1], true)
  1696.     begin
  1697.         type_keys({returnKey});
  1698.         return RStatus("SelectLaserWriter: LaserWriter is already the current printer type.", v_level);
  1699.     end;
  1700.     
  1701.     else
  1702.     begin
  1703.         type_keys({returnKey});
  1704.         if not (select_menuItem('Chooser', 1) and await_presence ([window t:'Chooser' o:1],,,,6))
  1705.             return RError("SelectLaserWriter: Failed to open the Chooser.",v_level);
  1706.         saveSpeed := typeSpeed(50);
  1707.         type_keys({'LaserWriter', 'latch', commandKey, 'q'}, 5);
  1708.         typeSpeed(saveSpeed);
  1709.         if await_presence ([staticText t:/You have changed your current printer.≈/ o:3 
  1710.                                 w:[window o:1 s:dialog] ],5,,,6) 
  1711.             type_keys({returnKey});
  1712.         
  1713.         await_presence ([application t:'Finder'],,,,6);
  1714.         select_menuItem('Page Setup…', 'File');
  1715.         if await_presence([staticText t:"LaserWriter Page Setup" w:1],5,,,6) 
  1716.             myResult := RStatus("SelectLaserWriter: Selected LaserWriter in the Chooser.", v_level);
  1717.         else
  1718.             myResult := RError("SelectLaserWriter: Failed to select LaserWriter in the Chooser.",1);
  1719.         type_keys({returnKey});
  1720.         if myResult
  1721.             return {0, myResult};
  1722.         else
  1723.             return {-1, myResult};
  1724.     end;
  1725. end;
  1726.  
  1727. #########################################################################
  1728. #    task            SelectLaserWriter300(pOptions, v_level)
  1729. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1730. #    Description:    Selects a LaserWriter300 by clicking on the modem port icon.
  1731. #                    Verifies by selecting Page Setup in the Finder and 
  1732. #                    checking staticText items in the dialog. 
  1733. #    Parameters:        pOptions:    list optional settings, e.g. name, setup paramters
  1734. #                    v_level:    verbosity level for log output
  1735. #    Returns:        { theErr, "theErrString" }
  1736. #    Examples:        SelectLaserWriter300({{'name',"Plodder"}});
  1737. #                    SelectLaserWriter300({});
  1738. #    Assumptions:    WARNING: This task does not check if an RDEV is 
  1739. #                    available before trying to select it. It could select 
  1740. #                    something you do not want. You can not "unselect".
  1741. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1742. #    History:
  1743. #        01/06/95    Tony Clancy        created
  1744. #        09/27/96    BRL/MSO            Added SPEC exception handling
  1745. #########################################################################
  1746. task SelectLaserWriter300( pOptions, v_level := 5)
  1747. begin
  1748.     if not select_menuItem('Page Setup…', 'File')
  1749.         return RError("SelectLaserWriter300: could not select Page Setup… from the Finder File menu", 1);
  1750.     await_presence([window s:dialog o:1],,,,6);
  1751.     
  1752.     if _MatchBoolean([staticText t:"LaserWriter 300 Page Setup" w:1], true)
  1753.     begin
  1754.         type_keys({returnKey});
  1755.         return RStatus("SelectLaserWriter300: LaserWriter 300 is already the current printer type.", v_level);
  1756.     end;
  1757.     else
  1758.     begin
  1759.         type_keys({returnKey});
  1760.         if not (select_menuItem('Chooser', 1) and await_presence ([window t:'Chooser' o:1],,,,6))
  1761.             return RError("SelectLaserWriter300: Failed to open the Chooser.",v_level);
  1762.         saveSpeed := typeSpeed(50);
  1763.         type_keys({'LaserWriter 300'}, 5);
  1764.         move_mouse({{300, 70}, 'rtw', 'click'});
  1765.         type_keys({'latch', commandkey, 'q'}, 5);
  1766.         typeSpeed(saveSpeed);
  1767.         if await_presence ([staticText t:/You have changed your current printer.≈/ o:3 
  1768.                                 w:[window o:1 s:dialog] ],5,,,6) 
  1769.             type_keys({returnKey});
  1770.         
  1771.         await_presence ([application t:'Finder'],,,,6);
  1772.         select_menuItem('Page Setup…', 'File');
  1773.         if await_presence([staticText t:"LaserWriter 300 Page Setup" w:1],5,,,6) 
  1774.             myResult := RStatus("SelectLaserWriter300: Selected LaserWriter 300 in the Chooser.", v_level);
  1775.         else
  1776.             myResult := RError("SelectLaserWriter300: Failed to select LaserWriter 300 in the Chooser.",1);
  1777.         type_keys({returnKey});
  1778.         if myResult
  1779.             return {0, myResult};
  1780.         else
  1781.             return {-1, myResult};
  1782.     end;
  1783. end;
  1784.  
  1785. #########################################################################
  1786. #    task            SelectLaserWriter8(pOptions, v_level)
  1787. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1788. #    Description:    Selects a LaserWriter 8 by typing its name in the Chooser.
  1789. #                    Verifies by selecting Page Setup in the Finder and 
  1790. #                    checking staticText items in the dialog. 
  1791. #    Parameters:        pOptions:    list optional settings, e.g. name, setup paramters
  1792. #                    v_level:    verbosity level for log output
  1793. #    Returns:        { theErr, "theErrString" }
  1794. #    Examples:        SelectLaserWriter8({{'name',"Plodder"}});
  1795. #    Examples:        SelectLaserWriter8({});
  1796. #    Assumptions:    WARNING: This task does not check if an RDEV is 
  1797. #                    available before trying to select it. It could select 
  1798. #                    something you do not want. You can not "unselect".
  1799. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1800. #    History:
  1801. #        09/15/94    SBR        created
  1802. #        09/27/96    BRL/MSO    Added SPEC exception handling
  1803. #########################################################################
  1804. task SelectLaserWriter8( pOptions, v_level := 5)
  1805. begin
  1806.     if not select_menuItem('Page Setup…', 'File')
  1807.         return RError("SelectLaserWriter8: could not select Page Setup… from the Finder File menu", 1);
  1808.     await_presence([window s:dialog o:1],,,,6);
  1809.     
  1810.     if _MatchBoolean([staticText t:"LaserWriter 8 Page Setup" w:1], true)
  1811.     begin
  1812.         type_keys({returnKey});
  1813.         return RStatus("SelectLaserWriter8: LaserWriter 8 is already the current printer type.", v_level);
  1814.     end;
  1815.     else
  1816.     begin
  1817.         type_keys({returnKey});
  1818.         if not (select_menuItem('Chooser', 1) and await_presence ([window t:'Chooser' o:1],,,,6))
  1819.             return RError("SelectLaserWriter8: Failed to open the Chooser.",v_level);
  1820.         saveSpeed := typeSpeed(50);
  1821.         type_keys({'LaserWriter 8', 'latch', commandKey, 'q'}, 5);
  1822.         typeSpeed(saveSpeed);
  1823.         if await_presence ([staticText t:/You have changed your current printer.≈/ o:3 
  1824.                                 w:[window o:1 s:dialog] ],5,,,6) 
  1825.             type_keys({returnKey});
  1826.         
  1827.         await_presence ([application t:'Finder'],,,,6);
  1828.         select_menuItem('Page Setup…', 'File');
  1829.         if await_presence([staticText t:"LaserWriter 8 Page Setup" w:1],5,,,6) 
  1830.             myResult := RStatus("SelectLaserWriter8: Selected LaserWriter 8 in the Chooser.", v_level);
  1831.         else
  1832.             myResult := RError("SelectLaserWriter8: Failed to select LaserWriter 8 in the Chooser.",1);
  1833.             
  1834.         type_keys({returnKey});
  1835.         if myResult
  1836.             return {0, myResult};
  1837.         else
  1838.             return {-1, myResult};
  1839.     end;
  1840. end;
  1841.  
  1842. #########################################################################
  1843. #    task            SelectLWSelect310(pOptions, v_level)
  1844. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1845. #    Description:    Selects an LW Select 310 by clicking on the modem port icon.
  1846. #                    Verifies by selecting Page Setup in the Finder and 
  1847. #                    checking staticText items in the dialog. 
  1848. #    Parameters:        pOptions:    list optional settings, e.g. name, setup paramters
  1849. #                    v_level:    verbosity level for log output
  1850. #    Returns:        { theErr, "theErrString" }
  1851. #    Examples:        SelectLWSelect310({{'name',"Plodder"}});
  1852. #    Examples:        SelectLWSelect310({});
  1853. #    Assumptions:    WARNING: This task does not check if an RDEV is 
  1854. #                    available before trying to select it. It could select 
  1855. #                    something you do not want. You can not "unselect".
  1856. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1857. #    History:
  1858. #        01/06/95    Tony Clancy        created
  1859. #        09/27/96    BRL/MSO            Added SPEC exception handling
  1860. #########################################################################
  1861. task SelectLWSelect310( pOptions, v_level := 5)
  1862. begin
  1863.     if not select_menuItem('Page Setup…', 'File')
  1864.         return RError("SelectLWSelect310: could not select Page Setup… from the Finder File menu", 1);
  1865.     await_presence([window s:dialog o:1],,,,6);
  1866.     
  1867.     if _MatchBoolean([staticText t:"LW Select 310 Page Setup" w:1], true)
  1868.     begin
  1869.         type_keys({returnKey});
  1870.         return RStatus("SelectLWSelect310: LW Select 310 is already the current printer type.", v_level);
  1871.     end;
  1872.     else
  1873.     begin
  1874.         type_keys({returnKey});
  1875.         if not (select_menuItem('Chooser', 1) and await_presence ([window t:'Chooser' o:1],,,,6))
  1876.             return RError("SelectLWSelect310: Failed to open the Chooser.",v_level);
  1877.         saveSpeed := typeSpeed(50);
  1878.         type_keys({'LaserWriter 300'}, 5);
  1879.         move_mouse({{340, 180}, 'rtw', 'click'});
  1880.         type_keys({'latch', commandKey, 'q'}, 5);
  1881.         typeSpeed(saveSpeed);
  1882.         if await_presence ([staticText t:/You have changed your current printer.≈/ o:3 
  1883.                                 w:[window o:1 s:dialog] ],5,,,6) 
  1884.             type_keys({returnKey});
  1885.         
  1886.         await_presence ([application t:'Finder'],,,,6);
  1887.         select_menuItem('Page Setup…', 'File');
  1888.         if await_presence([staticText t:"LW Select 310 Page Setup" w:1],5,,,6) 
  1889.             myResult := RStatus("SelectLWSelect310: Selected LW Select 310 in the Chooser.", v_level);
  1890.         else
  1891.             myResult := RError("SelectLWSelect310: Failed to select LW Select 310 in the Chooser.",1);
  1892.             
  1893.         type_keys({returnKey});
  1894.         if myResult
  1895.             return {0, myResult};
  1896.         else
  1897.             return {-1, myResult};
  1898.     end;
  1899. end;
  1900.  
  1901. #########################################################################
  1902. #    task            SelectLQATImageWriter(pOptions, v_level)
  1903. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1904. #    Description:    Selects an LQ AppleTalk ImageWriter by typing its name in the Chooser.
  1905. #                    Verifies by selecting Page Setup in the Finder and 
  1906. #                    checking staticText items in the dialog. 
  1907. #    Parameters:        pOptions:    list optional settings, e.g. name, setup paramters
  1908. #                    v_level:    verbosity level for log output
  1909. #    Returns:        { theErr, "theErrString" }
  1910. #    Examples:        SelectLQATImageWriter({});
  1911. #    Assumptions:    WARNING: This task does not check if an RDEV is 
  1912. #                    available before trying to select it. It could select 
  1913. #                    something you do not want. You can not "unselect".
  1914. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1915. #    History:
  1916. #        01/06/95    Tony Clancy        created
  1917. #        09/27/96    BRL/MSO            Added SPEC exception handling
  1918. #########################################################################
  1919. task SelectLQATImageWriter( pOptions, v_level := 5)
  1920. begin
  1921.     if not select_menuItem('Page Setup…', 'File')
  1922.         return RError("SelectLQATImageWriter: could not select Page Setup… from the Finder File menu", 1);
  1923.     await_presence([window s:dialog o:1],,,,6);
  1924.     
  1925.     if _MatchBoolean([staticText t:"AppleTalk ImageWriter LQ" w:1], true)
  1926.     begin
  1927.         type_keys({returnKey});
  1928.         return RStatus("SelectLQATImageWriter: LQ AppleTalk ImageWriter is already the current printer type.", v_level);
  1929.     end;
  1930.     else
  1931.     begin
  1932.         type_keys({returnKey});
  1933.         if not (select_menuItem('Chooser', 1) and await_presence ([window t:'Chooser' o:1],,,,6))
  1934.             return RError("SelectLQATImageWriter: Failed to open the Chooser.",v_level);
  1935.         saveSpeed := typeSpeed(50);
  1936.         type_keys({'LQ AppleTalk', 'latch', commandkey, 'q'}, 5);
  1937.         if await_presence ([staticText t:/You have changed your current printer.≈/ o:3 
  1938.                                 w:[window o:1 s:dialog] ],5,,,6) 
  1939.             type_keys({returnKey});
  1940.         await_presence ([application t:'Finder'],,,,6);
  1941.         select_menuItem('Page Setup…', 'File');
  1942.         if await_presence([staticText t:"AppleTalk ImageWriter LQ" w:1],5,,,6) 
  1943.             myResult := RStatus("SelectLQATImageWriter: Selected LQ AppleTalk ImageWriter in the Chooser.", v_level);
  1944.         else
  1945.             myResult := RError("SelectLQATImageWriter: Failed to select LQ AppleTalk ImageWriter in the Chooser.",1);
  1946.         type_keys({returnKey});
  1947.         if myResult
  1948.             return {0, myResult};
  1949.         else
  1950.             return {-1, myResult};
  1951.     end;
  1952. end;
  1953.  
  1954. #########################################################################
  1955. #    task            SelectLQImageWriter(pOptions, v_level)
  1956. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1957. #    Description:    Selects an LQ ImageWriter by clicking on the modem port icon.
  1958. #                    Verifies by selecting Page Setup in the Finder and 
  1959. #                    checking staticText items in the dialog. 
  1960. #    Parameters:        pOptions:    list optional settings, e.g. name, setup paramters
  1961. #                    v_level:    verbosity level for log output
  1962. #    Returns:        { theErr, "theErrString" }
  1963. #    Examples:        SelectLQImageWriter({});
  1964. #    Assumptions:    WARNING: This task does not check if an RDEV is 
  1965. #                    available before trying to select it. It could select 
  1966. #                    something you do not want. You can not "unselect".
  1967. #                    We can only use the modem port as if we are to use the 
  1968. #                    printer port then we'll have to turn off Appletalk.
  1969. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1970. #    History:
  1971. #        01/06/95    Tony Clancy        created
  1972. #        09/27/96    BRL/MSO            Added SPEC exception handling
  1973. #########################################################################
  1974. task SelectLQImageWriter( pOptions, v_level := 5)
  1975. begin
  1976.     if not select_menuItem('Page Setup…', 'File')
  1977.         return RError("SelectLQImageWriter: could not select Page Setup… from the Finder File menu", 1);
  1978.     await_presence([window s:dialog o:1],,,,6);
  1979.     
  1980.     if _MatchBoolean([staticText t:"LQ ImageWriter" w:1], true)
  1981.     begin
  1982.         type_keys({returnKey});
  1983.         return RStatus("SelectLQImageWriter: LQ ImageWriter is already the current printer type.", v_level);
  1984.     end;
  1985.     else
  1986.     begin
  1987.         type_keys({returnKey});
  1988.         if not (select_menuItem('Chooser', 1) and await_presence ([window t:'Chooser' o:1],,,,6))
  1989.             return RError("SelectLQImageWriter: Failed to open the Chooser.",v_level);
  1990.         saveSpeed := typeSpeed(50);
  1991.         type_keys({'LQ ImageWriter'}, 5);
  1992.         move_mouse({{340, 180}, 'rtw', 'click'});
  1993.         type_keys({'latch', commandkey, 'q'}, 5);
  1994.         if await_presence ([staticText t:/You have changed your current printer.≈/ o:3 
  1995.                                 w:[window o:1 s:dialog] ],5,,,6) 
  1996.             type_keys({returnKey});
  1997.         await_presence ([application t:'Finder'],,,,6);
  1998.         select_menuItem('Page Setup…', 'File');
  1999.         if await_presence([staticText t:"LQ ImageWriter" w:1],5,,,6) 
  2000.             myResult := RStatus("SelectLQImageWriter: Selected LQ ImageWriter in the Chooser.", v_level);
  2001.         else
  2002.             myResult := RError("SelectLQImageWriter: Failed to select LQ ImageWriter in the Chooser.",1);
  2003.         type_keys({returnKey});
  2004.         if myResult
  2005.             return {0, myResult};
  2006.         else
  2007.             return {-1, myResult};
  2008.     end;
  2009. end;
  2010.  
  2011. #########################################################################
  2012. #    task            SelectPersonalLaserWriterSC(pOptions, v_level)
  2013. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2014. #    Description:    Selects a Personal LaserWriter SC by typing its name in the Chooser.
  2015. #                    Verifies by selecting Page Setup in the Finder and 
  2016. #                    checking staticText items in the dialog. 
  2017. #    Parameters:        pOptions:    list optional settings, e.g. name, setup paramters
  2018. #                    v_level:    verbosity level for log output
  2019. #    Returns:        { theErr, "theErrString" }
  2020. #    Examples:        SelectPersonalLaserWriterSC({{'name',"Plodder"}});
  2021. #                    SelectPersonalLaserWriterSC({});
  2022. #    Assumptions:    WARNING: This task does not check if an RDEV is 
  2023. #                    available before trying to select it. It could select 
  2024. #                    something you do not want. You can not "unselect".
  2025. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2026. #    History:
  2027. #        01/06/95    Tony Clancy        created
  2028. #        09/27/96    BRL/MSO            Added SPEC exception handling
  2029. #########################################################################
  2030. task SelectPersonalLaserWriterSC( pOptions, v_level := 5)
  2031. begin
  2032.     if not select_menuItem('Page Setup…', 'File')
  2033.         return RError("SelectPersonalLaserWriterSC: could not select Page Setup… from the Finder File menu", 1);
  2034.     await_presence([window s:dialog o:1],,,,6);
  2035.     
  2036.     if _MatchBoolean([staticText t:"Personal LaserWriter SC" w:1], true)
  2037.     begin
  2038.         type_keys({returnKey});
  2039.         return RStatus("SelectPersonalLaserWriterSC: Personal LaserWriter SC is already the current printer type.", v_level);
  2040.     end;
  2041.     else
  2042.     begin
  2043.         type_keys({returnKey});
  2044.         if not (select_menuItem('Chooser', 1) and await_presence ([window t:'Chooser' o:1],,,,6))
  2045.             return RError("SelectPersonalLaserWriterSC: Failed to open the Chooser.",v_level);
  2046.         saveSpeed := typeSpeed(50);
  2047.         
  2048. #    The 'SC' part of 'Personal LaserWriter SC' is left out as the wrong printer is selected when this is left in.
  2049.         type_keys({'Personal LaserWriter', 'latch', commandkey, 'q'}, 5);
  2050.         if await_presence ([staticText t:/You have changed your current printer.≈/ o:3 
  2051.                                 w:[window o:1 s:dialog] ],5,,,6) 
  2052.             type_keys({returnKey});
  2053.         await_presence ([application t:'Finder'],,,,6);
  2054.         select_menuItem('Page Setup…', 'File');
  2055.         if await_presence([staticText t:"Personal LaserWriter SC" w:1],5,,,6) 
  2056.             myResult := RStatus("SelectPersonalLaserWriterSC: Selected Personal LaserWriter SC in the Chooser.", v_level);
  2057.         else
  2058.             myResult := RError("SelectPersonalLaserWriterSC: Failed to select Personal LaserWriter SC in the Chooser.",1);
  2059.         type_keys({returnKey});
  2060.         if myResult
  2061.             return {0, myResult};
  2062.         else
  2063.             return {-1, myResult};
  2064.     end;
  2065. end;
  2066.  
  2067. #########################################################################
  2068. #    task            SelectPersonalLWLS(pOptions, v_level)
  2069. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2070. #    Description:    Selects a Personal LW LS by clicking on the modem port icon.
  2071. #                    Verifies by selecting Page Setup in the Finder and 
  2072. #                    checking staticText items in the dialog. 
  2073. #    Parameters:        pOptions:    list optional settings, e.g. name, setup paramters
  2074. #                    v_level:    verbosity level for log output
  2075. #    Returns:        { theErr, "theErrString" }
  2076. #    Examples:        SelectPersonalLWLS({});
  2077. #    Assumptions:    WARNING: This task does not check if an RDEV is 
  2078. #                    available before trying to select it. It could select 
  2079. #                    something you do not want. You can not "unselect".
  2080. #                    We can only use the modem port as if we are to use the 
  2081. #                    printer port then we'll have to turn off Appletalk.
  2082. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2083. #    History:
  2084. #        01/06/95    Tony Clancy        created
  2085. #        09/27/96    BRL/MSO            Added SPEC exception handling
  2086. #########################################################################
  2087. task SelectPersonalLWLS( pOptions, v_level := 5)
  2088. begin
  2089.     if not select_menuItem('Page Setup…', 'File')
  2090.         return RError("SelectPersonalLWLS: could not select Page Setup… from the Finder File menu", 1);
  2091.     await_presence([window s:dialog o:1],,,,6);
  2092.     
  2093.     if _MatchBoolean([staticText t:"Personal LW LS" w:1], true)
  2094.     begin
  2095.         type_keys({returnKey});
  2096.         return RStatus("SelectPersonalLWLS: Personal LW LS is already the current printer type.", v_level);
  2097.     end;
  2098.     else
  2099.     begin
  2100.         type_keys({returnKey});
  2101.         if not (select_menuItem('Chooser', 1) and await_presence ([window t:'Chooser' o:1],,,,6))
  2102.             return RError("SelectPersonalLWLS: Failed to open the Chooser.",v_level);
  2103.         saveSpeed := typeSpeed(50);
  2104.         
  2105. #    The 'LS' part of 'Personal LW LS' is left out as the wrong printer is selected when this is left in.
  2106.         type_keys ({'Personal LW'});
  2107.         move_mouse({{340, 180}, 'rtw', 'click'});
  2108.         type_keys({'latch', commandkey, 'q'}, 5);
  2109.         if await_presence ([staticText t:/You have changed your current printer.≈/ o:3 
  2110.                                 w:[window o:1 s:dialog] ],5,,,6) 
  2111.             type_keys({returnKey});
  2112.         await_presence ([application t:'Finder'],,,,6);
  2113.         select_menuItem('Page Setup…', 'File');
  2114.         if await_presence([staticText t:"Personal LW LS" w:1],5,,,6) 
  2115.             myResult := RStatus("SelectPersonalLWLS: Selected Personal LW LS in the Chooser.", v_level);
  2116.         else
  2117.             myResult := RError("SelectPersonalLWLS: Failed to select Personal LW LS in the Chooser.",1);
  2118.         type_keys({returnKey});
  2119.         if myResult
  2120.             return {0, myResult};
  2121.         else
  2122.             return {-1, myResult};
  2123.     end;
  2124. end;
  2125.  
  2126. #########################################################################
  2127. #    task            SelectStyleWriter(pOptions, v_level)
  2128. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2129. #    Description:    Selects a StyleWriter by clicking on the modem port icon.
  2130. #                    Verifies by selecting Page Setup in the Finder and 
  2131. #                    checking staticText items in the dialog. 
  2132. #    Parameters:        pOptions:    list optional settings, e.g. name, setup paramters
  2133. #                    v_level:    verbosity level for log output
  2134. #    Returns:        { theErr, "theErrString" }
  2135. #    Examples:        SelectStyleWriter({});
  2136. #    Assumptions:    WARNING: This task does not check if an RDEV is 
  2137. #                    available before trying to select it. It could select 
  2138. #                    something you do not want. You can not "unselect".
  2139. #                    We can only use the modem port as if we are to use the 
  2140. #                    printer port then we'll have to turn off Appletalk.
  2141. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2142. #    History:
  2143. #        01/06/95    Tony Clancy        created
  2144. #        09/27/96    BRL/MSO            Added SPEC exception handling
  2145. #########################################################################
  2146. task SelectStyleWriter( pOptions, v_level := 5)
  2147. begin
  2148.     if not select_menuItem('Page Setup…', 'File')
  2149.         return RError("SelectStyleWriter: could not select Page Setup… from the Finder File menu", 1);
  2150.     await_presence([window s:dialog o:1],,,,6);
  2151.     
  2152.     if _MatchBoolean([staticText t:"StyleWriter" w:1], true)
  2153.     begin
  2154.         type_keys({returnKey});
  2155.         return RStatus("SelectStyleWriter: StyleWriter is already the current printer type.", v_level);
  2156.     end;
  2157.     else
  2158.     begin
  2159.         type_keys({returnKey});
  2160.         if not (select_menuItem('Chooser', 1) and await_presence ([window t:'Chooser' o:1],,,,6))
  2161.             return RError("SelectStyleWriter: Failed to open the Chooser.",v_level);
  2162.         saveSpeed := typeSpeed(50);
  2163.         type_keys ({'StyleWriter'});
  2164.         move_mouse({{340, 180}, 'rtw', 'click'});
  2165.         type_keys({'latch', commandkey, 'q'}, 5);
  2166.         if await_presence ([staticText t:/You have changed your current printer.≈/ o:3 
  2167.                                 w:[window o:1 s:dialog] ],5,,,6) 
  2168.             type_keys({returnKey});
  2169.         await_presence ([application t:'Finder'],,,,6);
  2170.         select_menuItem('Page Setup…', 'File');
  2171.         if await_presence([staticText t:"StyleWriter" w:1],5,,,6) 
  2172.             myResult := RStatus("SelectStyleWriter: Selected StyleWriter in the Chooser.", v_level);
  2173.         else
  2174.             myResult := RError("SelectStyleWriter: Failed to select StyleWriter in the Chooser.",1);
  2175.         type_keys({returnKey});
  2176.         if myResult
  2177.             return {0, myResult};
  2178.         else
  2179.             return {-1, myResult};
  2180.     end;
  2181. end;
  2182.  
  2183. #########################################################################
  2184. #    task            SelectStyleWriterII(pOptions, v_level)
  2185. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2186. #    Description:    Selects a StyleWriter II by clicking on the modem port icon.
  2187. #                    Verifies by selecting Page Setup in the Finder and 
  2188. #                    checking staticText items in the dialog. 
  2189. #    Parameters:        pOptions:    list optional settings, e.g. name, setup paramters
  2190. #                    v_level:    verbosity level for log output
  2191. #    Returns:        { theErr, "theErrString" }
  2192. #    Examples:        SelectStyleWriterII({});
  2193. #    Assumptions:    WARNING: This task does not check if an RDEV is 
  2194. #                    available before trying to select it. It could select 
  2195. #                    something you do not want. You can not "unselect".
  2196. #                    We can only use the modem port as if we are to use the 
  2197. #                    printer port then we'll have to turn off Appletalk.
  2198. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2199. #    History:
  2200. #        01/06/95    Tony Clancy        created
  2201. #        09/27/96    BRL/MSO            Added SPEC exception handling
  2202. #########################################################################
  2203. task SelectStyleWriterII( pOptions, v_level := 5)
  2204. begin
  2205.     if not select_menuItem('Page Setup…', 'File')
  2206.         return RError("SelectStyleWriterII: could not select Page Setup… from the Finder File menu", 1);
  2207.     await_presence([window s:dialog o:1],,,,6);
  2208.     
  2209.     if _MatchBoolean([staticText t:"StyleWriter II" w:1], true)
  2210.     begin
  2211.         type_keys({returnKey});
  2212.         return RStatus("SelectStyleWriter: StyleWriter II is already the current printer type.", v_level);
  2213.     end;
  2214.     else
  2215.     begin
  2216.         type_keys({returnKey});
  2217.         if not (select_menuItem('Chooser', 1) and await_presence ([window t:'Chooser' o:1],,,,6))
  2218.             return RError("SelectStyleWriterII: Failed to open the Chooser.",v_level);
  2219.         saveSpeed := typeSpeed(50);
  2220.         type_keys ({'StyleWriter II'});
  2221.         move_mouse({{300, 70}, 'rtw', 'click'});
  2222.         type_keys({'latch', commandkey, 'q'}, 5);
  2223.         if await_presence ([staticText t:/You have changed your current printer.≈/ o:3 
  2224.                                 w:[window o:1 s:dialog] ],5,,,6) 
  2225.             type_keys({returnKey});
  2226.         await_presence ([application t:'Finder'],,,,6);
  2227.         select_menuItem('Page Setup…', 'File');
  2228.         if await_presence([staticText t:"StyleWriter II" w:1],5,,,6) 
  2229.             myResult := RStatus("SelectStyleWriterII: Selected StyleWriter II in the Chooser.", v_level);
  2230.         else
  2231.             myResult := RError("SelectStyleWriterII: Failed to select StyleWriter II in the Chooser.",1);
  2232.         type_keys({returnKey});
  2233.         if myResult
  2234.             return {0, myResult};
  2235.         else
  2236.             return {-1, myResult};
  2237.     end;
  2238. end;
  2239.  
  2240. #########################################################################
  2241. #    task            SelectColorSW2400(pSettings, v_level)
  2242. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2243. #    Description:    Selects the Color StyleWriter 2400 by clicking on the modem port icon.
  2244. #                    Verifies by selecting Page Setup in the Finder and 
  2245. #                    checking staticText items in the dialog. 
  2246. #    Parameters:        pSettings:    list optional settings, e.g. name, setup paramters
  2247. #                    v_level:    verbosity level for log output
  2248. #    Returns:        { theErr, "theErrString" }
  2249. #    Examples:        SelectColorSW2400({});
  2250. #    Assumptions:    WARNING: This task does not check if an RDEV is 
  2251. #                    available before trying to select it. It could select 
  2252. #                    something you do not want. You can not "unselect".
  2253. #                    We can only use the modem port as if we are to use the 
  2254. #                    printer port then we'll have to turn off Appletalk.
  2255. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2256. #    History:
  2257. #        09/05/95    MSO        created, based on SelectStyleWriterII task by Tony Clancy
  2258. #        09/27/96    BRL/MSO    Added SPEC exception handling
  2259. #########################################################################
  2260. task SelectColorSW2400( pOptions, v_level := 5)
  2261. begin
  2262.     if not select_menuItem('Page Setup…', 'File')
  2263.         return RError("SelectColorSW2400: could not select Page Setup… from the Finder File menu", 1);
  2264.     await_presence([window s:dialog o:1],,,,6);
  2265.     
  2266.     if _MatchBoolean([staticText t:"Color StyleWriter 2400 Page Setup" w:1], true)
  2267.     begin
  2268.         type_keys({returnKey});
  2269.         return RStatus("SelectColorSW2400: Color StyleWriter 2400 is already the current printer type.", v_level);
  2270.     end;
  2271.     else
  2272.     begin
  2273.         type_keys({returnKey});
  2274.         if not (select_menuItem('Chooser', 1) and await_presence ([window t:'Chooser' o:1],,,,6))
  2275.             return RError("SelectColorSW2400: Failed to open the Chooser.",v_level);
  2276.         saveSpeed := typeSpeed(50);
  2277.         type_keys ({'Color SW 2400'});
  2278.         move_mouse({{300, 70}, 'rtw', 'click'});
  2279.         type_keys({'latch', commandkey, 'q'}, 5);
  2280.         if await_presence ([staticText t:/You have changed your current printer.≈/ o:3 
  2281.                                 w:[window o:1 s:dialog] ],5,,,6) 
  2282.             type_keys({returnKey});
  2283.         await_presence ([application t:'Finder'],,,,6);
  2284.         select_menuItem('Page Setup…', 'File');
  2285.         if await_presence([staticText t:"Color StyleWriter 2400 Page Setup" w:1],5,,,6) 
  2286.             myResult := RStatus("SelectColorSW2400: Selected Color StyleWriter 2400 in the Chooser.", v_level);
  2287.         else
  2288.             myResult := RError("SelectColorSW2400: Failed to select Color StyleWriter 2400 in the Chooser.",1);
  2289.         type_keys({returnKey});
  2290.         if myResult
  2291.             return {0, myResult};
  2292.         else
  2293.             return {-1, myResult};
  2294.     end;
  2295. end;
  2296.  
  2297.  
  2298. #########################################################################
  2299. #    task            SelectLaserWriterGX( pOptions, v_level)
  2300. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2301. #    Description:    Selects the LaserWriter GX as the default GX printer.
  2302. #                    Verifies by using SelectDesktopPrinter() task. 
  2303. #    Parameters:        pOptions:    list of settings
  2304. #                        [1]:    String name of file on desktop 
  2305. #                                (default to 'LaserWriter GX')
  2306. #                        [2]:    List of optional Get Info Description fields;
  2307. #                                see VerifyGetInfo() task for details (can be empty)
  2308. #                        [3]:    List of optional LaserWriter GX setting details;
  2309. #                                currently unused (can be empty)
  2310. #                    v_level:    verbosity level for log output
  2311. #    Returns:        { theErr, "theErrString" }
  2312. #    Examples:        SelectLaserWriterGX({"The Printer Name"});
  2313. #    Assumptions:    1) WARNING: This task does not check if an RDEV is 
  2314. #                    available before trying to select it. It could select 
  2315. #                    something you do not want. You can not "unselect".
  2316. #                    2) Finder is the front application
  2317. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2318. #    History:
  2319. #        06/01/96    MSO        created, based on SelectPDDMakerGX by SBR (Radar 1293559)
  2320. #        09/27/96    BRL/MSO    Added SPEC exception handling
  2321. #########################################################################
  2322. task SelectLaserWriterGX( pOptions := {}, v_level := 5)
  2323. begin
  2324.     if (card pOptions) = 0
  2325.         pOptions := pOptions + {'LaserWriter GX'};
  2326.     while (card pOptions) < 3
  2327.         pOptions := pOptions + {{}};
  2328.     
  2329.     printerFileName := pOptions[1];
  2330.     printerGetInfoDescription := pOptions[2] + {{ 'Type', 'LaserWriter GX'}};
  2331.     printerSetupDetails := pOptions[3];
  2332.  
  2333.     if SelectDesktopPrinter( {printerFileName, printerGetInfoDescription} )
  2334.         return {0, "SelectLaserWriterGX: LaserWriter GX is the default desktop printer"};
  2335.     
  2336.     if not (select_menuItem('Chooser', 1) and await_presence ([window t:'Chooser' o:1],,,,6))
  2337.         return {-1, RError("SelectLaserWriterGX: Failed to open the Chooser.",v_level)};
  2338.  
  2339.     #chooserRect := _Match([window o:1]).r;
  2340.     try
  2341.         match[window o:1 r:?chooserRect];
  2342.     catch theError
  2343.         ExceptionDispatcher(theError,,{"Match 1 in SelectLaserWriterGX", { pOptions, v_level}});
  2344.     
  2345.     saveSpeed := typeSpeed(50);
  2346.     type_keys ({'LaserWriter GX'});
  2347.     typeSpeed(saveSpeed);
  2348.  
  2349.     wait(1);
  2350.     if not LocateString('LaserWriter GX', chooserRect, 'Geneva', 9, 0, 
  2351.                          {65535, 65535, 65535}, {0, 0, 0})
  2352.         return {-1, RError("SelectLaserWriterGX: LaserWriter GX is not in the Chooser.",v_level)};
  2353.  
  2354.     wait(2);
  2355.     clickMe := LocateString(printerFileName, chooserRect, 'Geneva', 12, 0);
  2356.     if isUndefined(clickMe)
  2357.         clickMe := LocateString(printerFileName, chooserRect, 'Geneva', 12, 0, 
  2358.                              {65535, 65535, 65535}, {0, 0, 0});
  2359.     if isUndefined(clickMe)
  2360.         return {-1, RError("SelectLaserWriterGX: {printerFileName} is not in the Chooser.",v_level)};
  2361.     else
  2362.         move_mouse({'absolute',{(clickMe[1] + clickMe[3])/2,(clickMe[2] + clickMe[4])/2},
  2363.                         'click'});
  2364.     
  2365.     if not await_presence([button t:'Create' e:true],,,,6)
  2366.         return {-1, RError("SelectLaserWriterGX: Create button not enabled in the Chooser.",v_level)};
  2367.     type_keys ({returnKey},5);
  2368.  
  2369.     if not await_presence([button t:'Setup' e:true],,,,6)
  2370.         return {-1, RError("SelectLaserWriterGX: Setup button not enabled in the Automatic setup dlog box.",v_level)};
  2371.     select_descriptor([button t:'Setup']);
  2372.  
  2373.     if not await_presence([window t:'Chooser' o:1],,,,6)
  2374.         return {-1, RError("SelectLaserWriterGX: Chooser window did not return.",v_level)};
  2375.  
  2376.     type_keys({'latch', commandkey, 'q'}, 5);
  2377.     await_presence ([application t:'Finder'],,,,6);
  2378.  
  2379.     type_keys({'latch',commandKey,'latch',shiftKey,'latch',optionKey, upArrowKey});
  2380.  
  2381.     # verify the new LaserWriter GX icon
  2382.     if not VerifyGetInfo(printerFileName,, true)
  2383.     begin
  2384.         RError("Could not find '{printerFileName}' LaserWriter GX printer.",v_level);    
  2385.         return {-1};
  2386.     end;
  2387.  
  2388.     if SelectDesktopPrinter( {printerFileName, printerGetInfoDescription} )
  2389.         myResult := RStatus("SelectLaserWriterGX: Created LaserWriter GX on the desktop.", v_level);
  2390.     else
  2391.         myResult := RError("SelectLaserWriterGX: Failed to create LaserWriter GX on the desktop.",1);
  2392.  
  2393.     if myResult
  2394.         return {0, myResult};
  2395.     else
  2396.         return {-1, myResult};
  2397. end;
  2398.  
  2399.  
  2400. #########################################################################
  2401. #    task            SelectColorSW2400GX( pOptions, v_level)
  2402. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2403. #    Description:    Selects the Color SW 2400 GX as the default GX printer.
  2404. #                    Verifies by using SelectDesktopPrinter() task. 
  2405. #    Parameters:        pOptions:    list of settings
  2406. #                        [1]:    String name of file on desktop 
  2407. #                                (default to 'Color SW 2400 GX')
  2408. #                        [2]:    List of optional Get Info Description fields;
  2409. #                                see VerifyGetInfo() task for details (can be empty)
  2410. #                        [3]:    List of optional Color SW 2400 GX setting details;
  2411. #                                currently unused (can be empty)
  2412. #                    v_level:    verbosity level for log output
  2413. #    Returns:        { theErr, "theErrString" }
  2414. #    Examples:        SelectColorSW2400GX({"The Printer Name"});
  2415. #    Assumptions:    1) WARNING: This task does not check if an RDEV is 
  2416. #                    available before trying to select it. It could select 
  2417. #                    something you do not want. You can not "unselect".
  2418. #                    2) Finder is the front application
  2419. #                    3) Selecting the modem port as if we are to use the 
  2420. #                    printer port then we'll have to turn off Appletalk.
  2421. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2422. #    History:
  2423. #        06/01/96    MSO        created, based on SelectPDDMakerGX by SBR (Radar 1293546)
  2424. #########################################################################
  2425. task SelectColorSW2400GX( pOptions := {}, v_level := 5)
  2426. begin
  2427.     if (card pOptions) = 0
  2428.         pOptions := pOptions + {'Color SW 2400 GX'};
  2429.     while (card pOptions) < 3
  2430.         pOptions := pOptions + {{}};
  2431.     
  2432.     printerFileName := pOptions[1];
  2433.     printerGetInfoDescription := pOptions[2] + {{ 'Type', 'Color SW 2400 GX'}};
  2434.     printerSetupDetails := pOptions[3];
  2435.     
  2436.     if SelectDesktopPrinter( {printerFileName, printerGetInfoDescription} )
  2437.         return {0, "SelectColorSW2400GX: Color SW 2400 GX is the default desktop printer"};
  2438.     
  2439.     if not (select_menuItem('Chooser', 1) and await_presence ([window t:'Chooser' o:1],,,,6))
  2440.         return {-1, RError("SelectColorSW2400GX: Failed to open the Chooser.",v_level)};
  2441.  
  2442.     chooserRect := _Match([window o:1]).r;
  2443.     
  2444.     saveSpeed := typeSpeed(50);
  2445.     type_keys ({'Color SW 2400 GX'});
  2446.     typeSpeed(saveSpeed);
  2447.     
  2448.     wait(1);
  2449.     if not LocateString('Color SW 2400 GX', chooserRect, 'Geneva', 9, 0, 
  2450.                          {65535, 65535, 65535}, {0, 0, 0})
  2451.         return {-1, RError("SelectColorSW2400GX: Color SW 2400 GX is not in the Chooser.",v_level)};
  2452.     
  2453.     wait(2);
  2454.     clickMe := LocateString('Modem Port', chooserRect, 'Geneva', 9, 0);
  2455.     if isUndefined(clickMe)
  2456.         clickMe := LocateString('Modem Port', chooserRect, 'Geneva', 9, 0, 
  2457.                              {65535, 65535, 65535}, {0, 0, 0});
  2458.     if isUndefined(clickMe)
  2459.         return {-1, RError("SelectColorSW2400GX: Modem Port is not in the Chooser.",v_level)};
  2460.     else
  2461.         move_mouse({'absolute',{(clickMe[1] + clickMe[3])/2,(clickMe[2] + clickMe[4])/2},
  2462.                         'click'});
  2463.  
  2464.     if not await_presence([button t:'Create' e:true],,,,6)
  2465.         return {-1, RError("SelectColorSW2400GX: Create button not enabled in the Chooser.",v_level)};
  2466.     type_keys ({returnKey},5);
  2467.     wait (2);
  2468.  
  2469.     type_keys({'latch', commandkey, 'q'}, 5);
  2470.     await_presence ([application t:'Finder'],,,,6);
  2471.  
  2472.     type_keys({'latch',commandKey,'latch',shiftKey,'latch',optionKey, upArrowKey});
  2473.  
  2474.     # select the new Color SW 2400 GX icon so we can change its name
  2475.     if not VerifyGetInfo('Color SW 2400 GX',, true)
  2476.     begin
  2477.         RError("Could not find '{printerFileName}' Color StyleWriter 2400 GX printer.",v_level);    
  2478.         return {-1};
  2479.     end;
  2480.     
  2481.     # type the new name for this Color SW 2400 GX icon
  2482.     type_keys({returnKey, printerFileName, returnKey});
  2483.  
  2484.     if SelectDesktopPrinter( {printerFileName, printerGetInfoDescription} )
  2485.         myResult := RStatus("SelectColorSW2400GX: Created Color SW 2400 GX on the desktop.", v_level);
  2486.     else
  2487.         myResult := RError("SelectColorSW2400GX: Failed to create Color SW 2400 GX on the desktop.",1);
  2488.  
  2489.     if myResult
  2490.         return {0, myResult};
  2491.     else
  2492.         return {-1, myResult};
  2493. end;
  2494.  
  2495.  
  2496. #########################################################################
  2497. #    task            SelectPDDMakerGX( pOptions, v_level)
  2498. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2499. #    Description:    Selects the PDD Maker GX as the default GX printer.
  2500. #                    Verifies by using SelectDesktopPrinter() task. 
  2501. #    Parameters:        pOptions:    list of settings
  2502. #                        [1]:    String name of file on desktop 
  2503. #                                (default to 'PDD Maker GX')
  2504. #                        [2]:    List of optional Get Info Description fields;
  2505. #                                see VerifyGetInfo() task for details (can be empty)
  2506. #                        [3]:    List of optional PPD Maker GX setting details;
  2507. #                                currently unused (can be empty)
  2508. #                    v_level:    verbosity level for log output
  2509. #    Returns:        { theErr, "theErrString" }
  2510. #    Examples:        SelectPDDMakerGX();
  2511. #    Assumptions:    1) WARNING: This task does not check if an RDEV is 
  2512. #                    available before trying to select it. It could select 
  2513. #                    something you do not want. You can not "unselect".
  2514. #                    2) Finder is the front application
  2515. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2516. #    History:
  2517. #        04/09/95    SBR        created
  2518. #########################################################################
  2519. task SelectPDDMakerGX( pOptions := {}, v_level := 5)
  2520. begin
  2521.     if (card pOptions) = 0
  2522.         pOptions := pOptions + {'PDD Maker GX'};
  2523.     while (card pOptions) < 3
  2524.         pOptions := pOptions + {{}};
  2525.     
  2526.     printerFileName := pOptions[1];
  2527.     printerGetInfoDescription := pOptions[2] + {{ 'Type', 'PDD Maker GX'}};
  2528.     printerSetupDetails := pOptions[3];
  2529.     
  2530.     if SelectDesktopPrinter( {printerFileName, printerGetInfoDescription} )
  2531.         return {0, "SelectPDDMakerGX: PDD Maker GX is the default desktop printer"};
  2532.     
  2533.     if not (select_menuItem('Chooser', 1) and await_presence ([window t:'Chooser' o:1],,,,6))
  2534.         return {-1, RError("SelectPDDMakerGX: Failed to open the Chooser.",v_level)};
  2535.  
  2536.     chooserRect := _Match([window o:1], true).r;
  2537.     
  2538.     saveSpeed := typeSpeed(50);
  2539.     type_keys ({'PDD Maker GX'});
  2540.     typeSpeed(saveSpeed);
  2541.     
  2542.     wait(1);
  2543.     if not LocateString('PDD Maker GX', chooserRect, 'Geneva', 9, 0, 
  2544.                          {65535, 65535, 65535}, {0, 0, 0})
  2545.         return {-1, RError("SelectPDDMakerGX: PDD Maker GX is not in the Chooser.",v_level)};
  2546.         
  2547.     clickMe := LocateString('PDDMaker', chooserRect, 'Geneva', 9, 0);
  2548.     if isUndefined(clickMe)
  2549.         clickMe := LocateString('PDDMaker', chooserRect, 'Geneva', 9, 0, 
  2550.                              {65535, 65535, 65535}, {0, 0, 0});
  2551.     if isUndefined(clickMe)
  2552.         return {-1, RError("SelectPDDMakerGX: PDDMaker is not in the Chooser.",v_level)};
  2553.     else
  2554.         move_mouse({'absolute',{(clickMe[1] + clickMe[3])/2,(clickMe[2] + clickMe[4])/2},
  2555.                         'click'});
  2556.     
  2557.     if not await_presence([button t:'Create' e:true],,,,6)
  2558.         return {-1, RError("SelectPDDMakerGX: Create button not enabled in the Chooser.",v_level)};
  2559.         
  2560.     type_keys({returnKey,'latch', commandkey, 'q'}, 5);
  2561.     await_presence ([application t:'Finder'],,,,6);
  2562.  
  2563.     type_keys({'latch',commandKey,'latch',shiftKey,'latch',optionKey, upArrowKey});
  2564.  
  2565.     # select the new PDD Maker GX icon so we can change its name
  2566.     if not VerifyGetInfo('PDD Maker GX',, true)
  2567.     begin
  2568.         RError("Could not find 'PDD Maker GX' to set its name to '{printerFileName}'.",v_level);    
  2569.         return {-1};
  2570.     end;
  2571.     
  2572.     # type the new name for this PDD Maker GX icon
  2573.     type_keys({returnKey, printerFileName, returnKey});
  2574.  
  2575.     if SelectDesktopPrinter( {printerFileName, printerGetInfoDescription} )
  2576.         myResult := RStatus("SelectPDDMakerGX: Created PDD Maker GX on the desktop.", v_level);
  2577.     else
  2578.         myResult := RError("SelectPDDMakerGX: Failed to create PDD Maker GX on the desktop.",1);
  2579.  
  2580.     if myResult
  2581.         return {0, myResult};
  2582.     else
  2583.         return {-1, myResult};
  2584. end;
  2585.  
  2586.  
  2587.  
  2588.  
  2589. (*_______________________________________________________________________________*)
  2590. task ensure_screen_depth( depthList := {}, v_level := 5 )
  2591. (*
  2592.     Description:    If not already at a depth in the list, attempt to set depth to 
  2593.                     the first value in the list, then 2nd, etc.
  2594.     Parameters:        depthList: list of integers, limited to { 1,2,4,8,16,24,32 }.
  2595.     Returns:        { originalDepth, newDepth } 
  2596.                     or {} if could not set to any of the values in the list
  2597.     Change History:
  2598.         01/17/93    SBR        Created
  2599. *)
  2600. begin
  2601.     originalDepth := VUAid('GetDepth');
  2602.     if isMember(originalDepth, depthList)
  2603.         return { originalDepth, originalDepth };
  2604.     println "Depth is {originalDepth}, not {depthList}.";
  2605.     i := 1;
  2606.     done := false;
  2607.     while not done and i <= card depthList begin
  2608.         newDepth := depthList[i];
  2609.         if isUndefined(VUAid('setDepth', {newDepth})) return {};
  2610.         if newDepth = VUAid('GetDepth') begin
  2611.             done := true;
  2612.             if select_menuItem('Calculator','') begin        #redraw menu bar
  2613.                 wait(1);
  2614.                 key_eq('q');
  2615.             end;
  2616.             return { originalDepth, newDepth };
  2617.         end;
  2618.         i := i + 1;
  2619.     end;
  2620.     return {};
  2621. end;
  2622.  
  2623.  
  2624.  
  2625. #########################################################################
  2626. #    task                    sys_vers(v_level)
  2627. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2628. #    Description:    Get the version of the system software running on the
  2629. #                    target machine.
  2630. #    Parameters:        v_level:    verbosity level for log output
  2631. #    Returns:        string compressed by removing periods, since it will be
  2632. #                    used to name files, etc.
  2633. #                    Returns empty string on failure.
  2634. #    Examples:        println sys_vers();
  2635. #    Assumptions:    None
  2636. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2637. #    History:
  2638. #        07/25/90        Alan Liu        Creation as part of GestaltLib.vu for 007
  2639. #        03/04/92        Jason Marsh        Incorporated into Clouseau.Lib
  2640. #        09/03/94        SBR                Added error handling for target access
  2641. #        09/27/96        BRL/MSO            Added SPEC exception handling
  2642. #########################################################################
  2643. task    sys_vers(v_level:=5)
  2644. begin
  2645.     long_vers := _Match([system]).v;
  2646.     if long_vers 
  2647.     begin
  2648.         (*abbreviate the version string*)
  2649.         vers := "";
  2650.         long_versLen := card long_vers;
  2651.         for i := 1 to long_versLen
  2652.         begin
  2653.             if (long_vers[i] = '(')
  2654.                 vers := vers + '-';
  2655.             else 
  2656.                 if not (long_vers[i] = '.' or long_vers[i] = ')')
  2657.                     vers := vers + long_vers[i];
  2658.         end;
  2659.     end;
  2660.     else vers := '';
  2661.     RStatus("sys_vers: {vers}",v_level);
  2662.     return vers;
  2663. end;
  2664.  
  2665.  
  2666. #########################################################################
  2667. #    task            VerifyGetInfo( pGetInfoFields, typeSelectItem, v_level )
  2668. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2669. #    Description:    Does a Get Info for an item in the front window of the Finder.
  2670. #    Parameters:        pFileName:    String name of file to verify (required)
  2671. #                    pGetInfoFields:    List of zero or more items comprising 
  2672. #                                    a Get Info window description:
  2673. #                        A Get Info window description consists of fields; 
  2674. #                        each field has two parts, the field ID and the 
  2675. #                        field contents, and are checked using the VU 2.1
  2676. #                        built-in LocateString() task. The field ID is located 
  2677. #                        first in Geneva 9 bold, and if there, the field contents
  2678. #                        are located to its right in Geneva 9 plain. All specified 
  2679. #                        field lists must match or the verify fails.
  2680. #                    typeSelectItem:    true:    type the item name to select it
  2681. #                                    false:    item is already selected (default)
  2682. #                    v_level:    verbosity level for log output
  2683. #    Returns:        true:    file name and all specified field matches
  2684. #                    false:    name or field mismatch
  2685. #    Examples (capitalization counts when using Locate String):
  2686. #                    VerifyGetInfo('this file');
  2687. #    
  2688. #                    VerifyGetInfo(    'that file',
  2689. #                                        {{ 'Kind', 'document'} });
  2690. #                            
  2691. #                    VerifyGetInfo(    'a clip of text',
  2692. #                                        {{ 'Kind', 'text clipping'},
  2693. #                                        { 'Version', 'n/a'} });
  2694. #    Assumptions:    VU 2.1; Finder is in front; Item's container is open and in front;
  2695. #                    Item is selected already (if typeSelectItem is false);
  2696. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2697. #    History:
  2698. #        04/09/95    SBR        Created
  2699. #        09/27/96    BRL/MSO    Added SPEC exception handling
  2700. #########################################################################
  2701. task    VerifyGetInfo( pFileName, pGetInfoFields := {}, typeSelectItem := false, v_level := 5 )
  2702. begin
  2703.     lastField := card pGetInfoFields;
  2704.     
  2705.     # type the name if needed
  2706.     if typeSelectItem
  2707.         type_keys({pFileName});
  2708.     
  2709.     # open Get Info window
  2710.     type_keys({'latch', commandKey, "i"});
  2711.     if not _MatchBoolean([window t:/{pFileName} Info≈/ o:1], true)
  2712.     begin
  2713.         key_eq('w',,v_level);
  2714.         RError("Could not find a file named '{pFileName}' in the front window.",v_level);
  2715.         return false;
  2716.     end;
  2717.  
  2718.     # Check specified options
  2719.     if lastField > 1
  2720.     begin
  2721.         try
  2722.             match [window o:1 r:?theInfoWindRect];
  2723.         catch theError
  2724.             ExceptionDispatcher(theError,,{"Match 1 in VerifyGetInfo", { pFileName, pGetInfoFields, typeSelectItem, v_level}});
  2725.         
  2726.         for thisField := 1 to lastField 
  2727.         begin
  2728.             tFieldID := pGetInfoFields[thisField][1];
  2729.             tFieldContents := pGetInfoFields[thisField][2];
  2730.             
  2731.             theFieldRect := LocateString(tFieldID, theInfoWindRect, 'Geneva', 9, 1);
  2732.             if not theFieldRect
  2733.             begin
  2734.                 key_eq('w',,v_level);                    # Close Get Info Window
  2735.                 RError("Could not locate Get Info field '{tFieldID}' for this file.",v_level);
  2736.                 return false;
  2737.             end;
  2738.  
  2739.             theFieldRect[3] := theFieldRect[3] + 130;    # Extend search rect to the right
  2740.             
  2741.             theFieldRect := LocateString(tFieldContents, theFieldRect, 'Geneva', 9, 0);
  2742.             if not theFieldRect
  2743.             begin
  2744.                 key_eq('w',,v_level);                    # Close Get Info Window
  2745.                 RError("Could not locate '{tFieldContents}' in field '{tFieldID}'.",v_level);
  2746.                 return false;
  2747.             end;
  2748.         end;
  2749.     end;
  2750.  
  2751.     key_eq('w',,v_level);            # Close Get Info Window
  2752.     return true;
  2753. end;
  2754.  
  2755.  
  2756. #########################################################################
  2757. #    task                    CheckExternalToolVersions(v_level)
  2758. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2759. #    Description:    Checks for the existence and correct versions of various external
  2760. #                    tools on the target and host. isVUAidInstalled() will automatically
  2761. #                    turn on Program Linking and set Guest access if needed. These are 
  2762. #                    all the required external tools. If they are not correct, exit script.
  2763. #                    This task should be called VERY early to save the operator some time
  2764. #                    if a tool is not there or is the wrong version.
  2765. #    Parameters:        none
  2766. #    Returns:        none - exits if unsuccsessful, returns to caller if successful  
  2767. #    Examples:        CheckExternalToolVersions();
  2768. #    Assumptions:    External tool libraries are declared in the file containing this task.
  2769. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2770. #    History:
  2771. #        09/07/94    SBR        Created
  2772. #        08/08/95    SBR        No longer quits "bad" tools, Radar 1275491
  2773. #        08/27/96    BRL        Updated FileTool version reference
  2774. #                            Removed FileTool OnTarget version reference/tool calls
  2775. #        09/27/96    BRL/MSO    Added SPEC exception handling
  2776. #        01/27/97    SBR        Use a STR# resource to store valid versions
  2777. #        01/27/97    SBR        Changed notification string from AutoGuest 2.0 to 2.1
  2778. #        01/27/97    SBR        Added FileToolHost, AEPost, Arbitrator, Ivy checks
  2779. #########################################################################
  2780. task CheckExternalToolVersions(v_level := 2)
  2781. begin
  2782.     RStatus("CheckExternalToolVersions: begin checking for required external tools...",v_level);
  2783.     saveCmdExcptn := commandExceptions(true);        # turn on try-throw-catch in VU 2.1
  2784.     
  2785.     # Get all allowed XTool versions from the STR# resources in this file.
  2786.     # Build full lists now, in case we need to use them in a failure report.
  2787.     VUAidVersionRsrc := 128;
  2788.     FileToolVersionRsrc := 129;
  2789.     OnTargetVersionRsrc := 130;
  2790.     AEPostVersionRsrc := 131;
  2791.     ArbitratorVersionRsrc := 132;
  2792.     IvyVersionRsrc := 133;
  2793.  
  2794.     #thisFile := FileOfTask();
  2795.  
  2796.     VUAidVersions := {};
  2797.     tIndex := 1;
  2798.     aGoodVersion := GetIndString( VUAidVersionRsrc, tIndex (*, thisFile*) );
  2799.     while aGoodVersion
  2800.     begin
  2801.         VUAidVersions := VUAidVersions + {aGoodVersion};
  2802.         tIndex := tIndex + 1;
  2803.         aGoodVersion := GetIndString( VUAidVersionRsrc, tIndex (*, thisFile*) );
  2804.     end;
  2805.     
  2806.     FileToolVersions := {};
  2807.     tIndex := 1;
  2808.     aGoodVersion := GetIndString( FileToolVersionRsrc, tIndex (*, thisFile*) );
  2809.     while aGoodVersion
  2810.     begin
  2811.         FileToolVersions := FileToolVersions + {aGoodVersion};
  2812.         tIndex := tIndex + 1;
  2813.         aGoodVersion := GetIndString( FileToolVersionRsrc, tIndex (*, thisFile*) );
  2814.     end;
  2815.     
  2816.     OnTargetVersions := {};
  2817.     tIndex := 1;
  2818.     aGoodVersion := GetIndString( OnTargetVersionRsrc, tIndex (*, thisFile*) );
  2819.     while aGoodVersion
  2820.     begin
  2821.         OnTargetVersions := OnTargetVersions + {aGoodVersion};
  2822.         tIndex := tIndex + 1;
  2823.         aGoodVersion := GetIndString( OnTargetVersionRsrc, tIndex (*, thisFile*) );
  2824.     end;
  2825.     
  2826.     AEPostVersions := {};
  2827.     tIndex := 1;
  2828.     aGoodVersion := GetIndString( AEPostVersionRsrc, tIndex (*, thisFile*) );
  2829.     while aGoodVersion
  2830.     begin
  2831.         AEPostVersions := AEPostVersions + {aGoodVersion};
  2832.         tIndex := tIndex + 1;
  2833.         aGoodVersion := GetIndString( AEPostVersionRsrc, tIndex (*, thisFile*) );
  2834.     end;
  2835.     
  2836.     ArbitratorVersions := {};
  2837.     tIndex := 1;
  2838.     aGoodVersion := GetIndString( ArbitratorVersionRsrc, tIndex (*, thisFile*) );
  2839.     while aGoodVersion
  2840.     begin
  2841.         ArbitratorVersions := ArbitratorVersions + {aGoodVersion};
  2842.         tIndex := tIndex + 1;
  2843.         aGoodVersion := GetIndString( ArbitratorVersionRsrc, tIndex (*, thisFile*) );
  2844.     end;
  2845.     
  2846.     IvyVersions := {};
  2847.     tIndex := 1;
  2848.     aGoodVersion := GetIndString( IvyVersionRsrc, tIndex (*, thisFile*) );
  2849.     while aGoodVersion
  2850.     begin
  2851.         IvyVersions := IvyVersions + {aGoodVersion};
  2852.         tIndex := tIndex + 1;
  2853.         aGoodVersion := GetIndString( IvyVersionRsrc, tIndex (*, thisFile*) );
  2854.     end;
  2855.     
  2856.     VUAidReturnLongIntegers(true);        # Each time it is launched, set it to return long integers
  2857.     
  2858.     #Let this task turn on Program Linking for us outside the try-throw-catch block
  2859.     if not isVUAidInstalled(true)
  2860.     begin
  2861.         RStatus("Can not initialize the VUAid external tool on the target.",1);  
  2862.         RStatus("The compatible versions of this external tool are: {VUAidVersions}.",1);
  2863.         RStatus("Target Preparation:",1);
  2864.         RStatus("Turn on Program Linking in the Sharing Setup Control Panel.",1);
  2865.         RStatus("Enable Program Linking for <Guest> in the Users & Groups Control Panel.",1);
  2866.         RStatus("Host Preparation:",1);
  2867.         RStatus("Install the AutoGuest INIT 2.1 Extension and restart, if it is not already installed.",1);
  2868.         RStatus("If these steps do not work, rebuild the desktop on the host and target.",1);
  2869.         RStatus(" Exiting script…",1);
  2870.         exit;
  2871.     end;
  2872.  
  2873.     try 
  2874.     begin
  2875.         ### Check VUAid version on the target.
  2876.         if VUAidVersions
  2877.         begin
  2878.             VUAidTargetVersion := VUAid('GetToolVersion')[2];
  2879.             VUAid('quit');
  2880.             if typeOf(VUAidTargetVersion) = 'list'
  2881.                 VUAidTargetVersion := VUAidTargetVersion[2];
  2882.     
  2883.             versionMatch := false;
  2884.     
  2885.             maxIndex := card VUAidVersions;
  2886.             for strIndex := 1 to maxIndex
  2887.             begin
  2888.                 aGoodVersion := VUAidVersions[strIndex];
  2889.                 versionMatch :=  ( (VUAidTargetVersion ~= /≈{aGoodVersion}≈/) or 
  2890.                                         (VUAidTargetVersion ~= /≈{aGoodVersion}≈∂n≈/) );
  2891.                 if versionMatch
  2892.                     maxIndex := 0;        # terminate the for loop early
  2893.             end;
  2894.             
  2895.             if not versionMatch
  2896.             begin
  2897.                 throw { 'VUAid', 'target', 'version', VUAidVersions, VUAidTargetVersion};
  2898.             end;
  2899.             else
  2900.             begin
  2901.                 RStatus("VUAid version '{aGoodVersion}' launched correctly on the target.",v_level + 1);
  2902.             end;
  2903.         end;
  2904.         
  2905.  
  2906.         ### Check FileTool version on the target.
  2907.         if FileToolVersions
  2908.         begin
  2909.             try 
  2910.             begin
  2911.                 toolInitRtnVal := FileTool('initialize', true);
  2912.                 if toolInitRtnVal[1] <> 0
  2913.                     throw toolInitRtnVal;
  2914.             end;
  2915.             catch theError
  2916.                 throw { 'FileTool', 'target', 'initialize', FileToolVersions, undefined, theError};
  2917.     
  2918.             FileToolTargetVersion := FileTool('GetToolVersion')[2];
  2919.             FileTool('quit');
  2920.             if typeOf(FileToolTargetVersion) = 'list'
  2921.                 FileToolTargetVersion := FileToolTargetVersion[2];
  2922.     
  2923.             versionMatch := false;
  2924.     
  2925.             maxIndex := card FileToolVersions;
  2926.             for strIndex := 1 to maxIndex
  2927.             begin
  2928.                 aGoodVersion := FileToolVersions[strIndex];
  2929.                 versionMatch :=  ( (FileToolTargetVersion ~= /≈{aGoodVersion}≈/) or 
  2930.                                         (FileToolTargetVersion ~= /≈{aGoodVersion}≈∂n≈/) );
  2931.                 if versionMatch
  2932.                     maxIndex := 0;        # terminate the for loop early
  2933.             end;
  2934.             
  2935.             if not versionMatch
  2936.             begin
  2937.                 throw { 'FileTool', 'target', 'version', FileToolVersions, FileToolTargetVersion};
  2938.             end;
  2939.             else
  2940.             begin
  2941.                 RStatus("FileTool version '{aGoodVersion}' launched correctly on the target.",v_level + 1);
  2942.             end;
  2943.     
  2944.             
  2945.             ### Check FileToolHost version on the host.
  2946.             try 
  2947.             begin
  2948.                 toolInitRtnVal := FileToolHost('initialize', false);
  2949.                 if toolInitRtnVal[1] <> 0
  2950.                     throw toolInitRtnVal;
  2951.             end;
  2952.             catch theError
  2953.                 throw { 'FileToolHost', 'host', 'initialize', FileToolVersions, undefined, theError};
  2954.     
  2955.             FileToolHostVersion := FileToolHost('GetToolVersion')[2];
  2956.             #FileToolHost('quit');             #Don't quit: another script might be using this...
  2957.             if typeOf(FileToolHostVersion) = 'list'
  2958.                 FileToolHostVersion := FileToolHostVersion[2];
  2959.     
  2960.             versionMatch := false;
  2961.     
  2962.             maxIndex := card FileToolVersions;
  2963.             for strIndex := 1 to maxIndex
  2964.             begin
  2965.                 aGoodVersion := FileToolVersions[strIndex];
  2966.                 versionMatch :=  ( (FileToolHostVersion ~= /≈{aGoodVersion}≈/) or 
  2967.                                         (FileToolHostVersion ~= /≈{aGoodVersion}≈∂n≈/) );
  2968.                 if versionMatch
  2969.                     maxIndex := 0;        # terminate the for loop early
  2970.             end;
  2971.             
  2972.             if not versionMatch
  2973.             begin
  2974.                 throw { 'FileToolHost', 'host', 'version', FileToolVersions, FileToolHostVersion};
  2975.             end;
  2976.             else
  2977.             begin
  2978.                 RStatus("FileToolHost version '{aGoodVersion}' launched correctly on the host.",v_level + 1);
  2979.             end;
  2980.         end;
  2981.         
  2982.         
  2983.         ### Check OnTarget version on the target.
  2984.         if OnTargetVersions
  2985.         begin
  2986.             try 
  2987.             begin
  2988.                 toolInitRtnVal := OnTarget('initialize', true);
  2989.                 if toolInitRtnVal[1] <> 0
  2990.                     throw toolInitRtnVal;
  2991.             end;
  2992.             catch theError
  2993.                 throw { 'OnTarget', 'target', 'initialize', OnTargetVersions, undefined, theError};
  2994.     
  2995.             OnTargetVersion := OnTarget('GetToolVersion')[2];
  2996.             OnTarget('quit');
  2997.             if typeOf(OnTargetVersion) = 'list'
  2998.                 OnTargetVersion := OnTargetVersion[2];
  2999.     
  3000.             versionMatch := false;
  3001.     
  3002.             maxIndex := card OnTargetVersions;
  3003.             for strIndex := 1 to maxIndex
  3004.             begin
  3005.                 aGoodVersion := OnTargetVersions[strIndex];
  3006.                 versionMatch :=  ( (OnTargetVersion ~= /≈{aGoodVersion}≈/) or 
  3007.                                         (OnTargetVersion ~= /≈{aGoodVersion}≈∂n≈/) );
  3008.                 if versionMatch
  3009.                     maxIndex := 0;        # terminate the for loop early
  3010.             end;
  3011.             
  3012.             if not versionMatch
  3013.             begin
  3014.                 throw { 'OnTarget', 'target', 'version', OnTargetVersions, OnTargetVersion};
  3015.             end;
  3016.             else
  3017.             begin
  3018.                 RStatus("OnTarget version '{aGoodVersion}' launched correctly on the target.",v_level + 1);
  3019.             end;
  3020.         end;
  3021.         
  3022.         
  3023.         ### Check AEPost version on the host.
  3024.         if AEPostVersions
  3025.         begin
  3026.             try 
  3027.             begin
  3028.                 toolInitRtnVal := AEPost('initialize', false);
  3029.                 if toolInitRtnVal[1] <> 0
  3030.                     throw toolInitRtnVal;
  3031.             end;
  3032.             catch theError
  3033.                 throw { 'AEPost', 'host', 'initialize', AEPostVersions, undefined, theError};
  3034.     
  3035.             AEPostVersion := AEPost('GetToolVersion')[2];
  3036.             #AEPost('quit');             #Don't quit: another script might be using this...
  3037.             if typeOf(AEPostVersion) = 'list'
  3038.                 AEPostVersion := AEPostVersion[2];
  3039.     
  3040.             versionMatch := false;
  3041.     
  3042.             maxIndex := card AEPostVersions;
  3043.             for strIndex := 1 to maxIndex
  3044.             begin
  3045.                 aGoodVersion := AEPostVersions[strIndex];
  3046.                 versionMatch :=  ( (AEPostVersion ~= /≈{aGoodVersion}≈/) or 
  3047.                                         (AEPostVersion ~= /≈{aGoodVersion}≈∂n≈/) );
  3048.                 if versionMatch
  3049.                     maxIndex := 0;        # terminate the for loop early
  3050.             end;
  3051.             
  3052.             if not versionMatch
  3053.             begin
  3054.                 throw { 'AEPost', 'host', 'version', AEPostVersions, AEPostVersion};
  3055.             end;
  3056.             else
  3057.             begin
  3058.                 RStatus("AEPost version '{aGoodVersion}' launched correctly on the host.",v_level + 1);
  3059.             end;
  3060.         end;
  3061.         
  3062.         
  3063.         ### Check Arbitrator version on the host.
  3064.         if ArbitratorVersions
  3065.         begin
  3066.             try 
  3067.             begin
  3068.                 toolInitRtnVal := Arbitrator('initialize', false);
  3069.                 if toolInitRtnVal[1] <> 0
  3070.                     throw toolInitRtnVal;
  3071.             end;
  3072.             catch theError
  3073.                 throw { 'Arbitrator', 'host', 'initialize', ArbitratorVersions, undefined, theError};
  3074.     
  3075.             ArbitratorVersion := Arbitrator('GetToolVersion')[2];
  3076.             #Arbitrator('quit');             #Don't quit: another script might be using this...
  3077.             if typeOf(ArbitratorVersion) = 'list'
  3078.                 ArbitratorVersion := ArbitratorVersion[2];
  3079.     
  3080.             versionMatch := false;
  3081.     
  3082.             maxIndex := card ArbitratorVersions;
  3083.             for strIndex := 1 to maxIndex
  3084.             begin
  3085.                 aGoodVersion := ArbitratorVersions[strIndex];
  3086.                 versionMatch :=  ( (ArbitratorVersion ~= /≈{aGoodVersion}≈/) or 
  3087.                                         (ArbitratorVersion ~= /≈{aGoodVersion}≈∂n≈/) );
  3088.                 if versionMatch
  3089.                     maxIndex := 0;        # terminate the for loop early
  3090.             end;
  3091.             
  3092.             if not versionMatch
  3093.             begin
  3094.                 throw { 'Arbitrator', 'host', 'version', ArbitratorVersions, ArbitratorVersion};
  3095.             end;
  3096.             else
  3097.             begin
  3098.                 RStatus("Arbitrator version '{aGoodVersion}' launched correctly on the host.",v_level + 1);
  3099.             end;
  3100.         end;
  3101.         
  3102.         
  3103.         ### Check Ivy version on the target.
  3104.         if IvyVersions
  3105.         begin
  3106.             try 
  3107.             begin
  3108.                 toolInitRtnVal := Ivy('initialize', true);
  3109.                 if toolInitRtnVal[1] <> 0
  3110.                     throw toolInitRtnVal;
  3111.             end;
  3112.             catch theError
  3113.                 throw { 'Ivy', 'target', 'initialize', IvyVersions, undefined, theError};
  3114.     
  3115.             IvyVersion := Ivy('GetToolVersion')[2];
  3116.             Ivy('quit');
  3117.             if typeOf(IvyVersion) = 'list'
  3118.                 IvyVersion := IvyVersion[2];
  3119.     
  3120.             versionMatch := false;
  3121.     
  3122.             maxIndex := card IvyVersions;
  3123.             for strIndex := 1 to maxIndex
  3124.             begin
  3125.                 aGoodVersion := IvyVersions[strIndex];
  3126.                 versionMatch :=  ( (IvyVersion ~= /≈{aGoodVersion}≈/) or 
  3127.                                         (IvyVersion ~= /≈{aGoodVersion}≈∂n≈/) );
  3128.                 if versionMatch
  3129.                     maxIndex := 0;        # terminate the for loop early
  3130.             end;
  3131.             
  3132.             if not versionMatch
  3133.             begin
  3134.                 throw { 'Ivy', 'target', 'version', IvyVersions, IvyVersion};
  3135.             end;
  3136.             else
  3137.             begin
  3138.                 RStatus("Ivy version '{aGoodVersion}' launched correctly on the target.",v_level + 1);
  3139.             end;
  3140.         end;
  3141.     end;
  3142.     catch theErr
  3143.     begin
  3144.         toolName := theErr[1];
  3145.         toolLoc := theErr[2];
  3146.         whatFailed := theErr[3];
  3147.         goodVersion := theErr[4];
  3148.         thisVersion := theErr[5];
  3149.         ToolInitRtnVal := theErr[6];
  3150.         
  3151.         RError("TTES Automated Scripts require the '{toolName}' external tool on the {toolLoc}.",1);
  3152.         if whatFailed = 'initialize'
  3153.         begin
  3154.             RError("{toolName} failed to initialize on the {toolLoc}.",1);
  3155.             if not isUndefined(ToolInitRtnVal)
  3156.                 RError("The error value returned was {ToolInitRtnVal}.",1);
  3157.             RError("You may need to rebuild the desktop on the {toolLoc}.",1);
  3158.         end;
  3159.         else if whatFailed = 'version'
  3160.         begin
  3161.             RError("The version just launched on the target is '{thisVersion}'.",1);
  3162.             RError("The compatible versions of this external tool are: {goodVersion}.",1);
  3163.             RError("You need to throw away version '{thisVersion}'.",1);
  3164.         end;
  3165.         RStatus(" Exiting script…",1);
  3166.         exit;
  3167.     end;
  3168.  
  3169.     commandExceptions( saveCmdExcptn );        # revert state of try-throw-catch
  3170. end;
  3171.  
  3172.  
  3173.  
  3174. #########################################################################
  3175. #    task                    SetUpGeneralControls(v_level)
  3176. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  3177. #    Description:    Turns off the shutdown warning that sits there blocking 
  3178. #                    Agent VU for 5 minutes after a crash. See Radar #1122664. 
  3179. #                    Also sets default standard file to the application's folder
  3180. #    Parameters:        v_level 
  3181. #    Returns:        none - exits if unsuccessful, returns to caller if successful  
  3182. #                    The task exits gracefully if there is no General Controls CP,
  3183. #                    or if the System is older than 7.5, or if the checkbox is not
  3184. #                    found in the General Controls CP.
  3185. #    Examples:        SetUpGeneralControls();
  3186. #    Assumptions:    VU 2.1 (control ordinality), General Controls CP 7.5.
  3187. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  3188. #    History:
  3189. #        02/22/95    SBR        Created as TurnOffShutDownWarning
  3190. #        07/26/95    SBR        changed to SetUpGeneralControls
  3191. #        09/27/96    BRL/MSO    Added SPEC exception handling
  3192. #########################################################################
  3193. task SetUpGeneralControls(v_level := 4)
  3194. begin
  3195. #    [checkBox t:'Warn me if computer was shut down improperly' o:46 r: { 38, 192, 278, 208 } e:true s:{ 0, 1 } h:0]
  3196. #    [radioButton t:'Documents folder.' o:47 r: { 273, 288, 463, 304 } e:true s:{ 0, 1 } h:0]
  3197. #    [radioButton t:'Last folder used in the application.' o:48 r: { 273, 271, 463, 287 } e:true s:{ 0, 1 } h:0]
  3198. #    [radioButton t:'Folder which contains the application.' o:49 r: { 273, 254, 463, 270 } e:true s:{ 1, 1 } h:0]
  3199.  
  3200.     RStatus("SetUpGeneralControls: Setting default folder and turning off shut down warning…",v_level);
  3201.     
  3202.     SavePreviousAppName := _Match([application ]).t;
  3203.     noFrontDialog := true;
  3204.     finderTwitchOK := twitch('Finder');                # Get to Finder, without a dialog
  3205.     if not finderTwitchOK
  3206.         RError("SetUpGeneralControls: Could not switch to Finder, is a dialog in front?", 2);
  3207.     
  3208.     else if ( _MatchBoolean( [window o:1 s:dialog], true) 
  3209.             or _MatchBoolean( [window o:1 s:movablemodal], true))
  3210.     begin
  3211.         noFrontDialog := dismiss_dialog();
  3212.     end;
  3213.         
  3214.     if finderTwitchOK and noFrontDialog
  3215.     begin
  3216.         closeCP := not _MatchBoolean([window t:'General Controls' 
  3217.                     k:{[checkBox t:'Warn me if computer was shut down improperly' o:46]}],true);
  3218.         if not open_control_panel('General Controls',true)    # Close window behind
  3219.             return;
  3220.         select_descriptor([checkBox t:/Warn me≈/ o:46 e:true s:{ 1, 1 }],1);    # Shutdown warning
  3221.         select_descriptor([radioButton t:'Folder which contains the application.' o:49 
  3222.                                 e:true s:{ 0, 1 }],1);    # Default standard file directory
  3223.         if closeCP
  3224.             close_window();
  3225.         
  3226.         twitch(SavePreviousAppName);
  3227.     end;
  3228.     else 
  3229.         RError("SetUpGeneralControls: Could turn on Program Linking, is a dialog in front?", 2);
  3230.     
  3231. end;
  3232.  
  3233.  
  3234. #########################################################################
  3235. #    task                    reset(v_level)
  3236. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  3237. #    Description:    attempts to dismiss any dialogs, close all windows, etc.
  3238. #                    If it fails, it aborts the script.
  3239. #    Parameters:        v_level:        verbosity level for log output
  3240. #    Returns:        Nothing
  3241. #    Examples:        reset();
  3242. #    Assumptions:    None
  3243. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  3244. #    History:
  3245. #        ???            ???        Created
  3246. #        12/03/96    Masa    changed call to abort_script(). Radar 1185040
  3247. #########################################################################
  3248. task reset(v_level := 5)
  3249. begin
  3250.     type_keys({returnKey});
  3251.     key_eq("w",5,v_level);
  3252.     if await_presence([window t:"Desktop" o:1]!,,,,6) return true;
  3253.     
  3254.     dismiss_dialog();
  3255.     type_keys({returnKey});
  3256.     key_eq("w",5,v_level);
  3257.     if await_presence([window t:"Desktop" o:1]!,,,,6) return true;
  3258.     
  3259.     twitch("Finder");
  3260.     key_eq("w",5,v_level);
  3261.     if await_presence([window t:"Desktop" o:1]!,,,,6) return true;
  3262.     
  3263.     abort_script("reset: Aborting script after failure to dismiss dialogs, close windows, etc.");
  3264. end;
  3265.  
  3266.  
  3267. #########################################################################
  3268. #    task                    target_info(v_level)
  3269. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  3270. #    Description:    prints out vital target information to the log
  3271. #    Parameters:        v_level:    verbosity level for log info.
  3272. #    Returns:        Nothing
  3273. #    Examples:        target_info();
  3274. #    Assumptions:    None
  3275. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  3276. #    History:
  3277. #        04/12/92    Jason Marsh        Created
  3278. #        4/19/94        Alan Winslow    Fixed Gestalt "addr" bug (temp treated as string 
  3279. #                                         instead of integer)
  3280. #        09/03/94    SBR        use target_machine since target_cpu was deleted
  3281. #        09/13/94    SBR        VU 2.1 Gestalt returns long integers; made changes for this.
  3282. #        09/27/96    BRL/MSO    Added SPEC exception handling
  3283. #########################################################################
  3284. task    target_info(v_level:= 2)
  3285. begin
  3286.     global vm, ThirtyTwoBit;
  3287.  
  3288.     cpuName := target_machine(v_level)[1];
  3289.     RStatus("target_cpu: ∂'{cpuName}∂'", v_level);
  3290.  
  3291.     sys_vers(v_level);
  3292.     
  3293.     if _Gestalt( "mmu ")[2] = 0
  3294.         vm := 'not available';
  3295.     else if _Gestalt( "vm  ")[2] = 1
  3296.         vm := 'on';
  3297.     else vm := 'off';
  3298.     RStatus("vm: {vm}", v_level);
  3299.                 
  3300.     temp := _Gestalt( "addr")[2];
  3301.     if temp = 0
  3302.         ThirtyTwoBit:= "not available";
  3303.     else if temp = 7
  3304.         ThirtyTwoBit := "on";
  3305.     else ThirtyTwoBit:= "off";
  3306.     RStatus ("32 bit: {ThirtyTwoBit}", v_level);
  3307.     
  3308.     ram := _Match([target], false).r;                # Amount of memory of the target machine
  3309.     RStatus ("Ram: {ram}");
  3310.     
  3311. end;
  3312.  
  3313.  
  3314. #########################################################################
  3315. #    task                    CPUstic()
  3316. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  3317. #    Description:    Looks at target CPU and check for the CPU's memory 
  3318. #                    capabilities. (i.e., VM, 32-bits, and RAM Disk)
  3319. #    Parameters:        None
  3320. #    Returns:        A list specifying the CPU's memory capabilities:
  3321. #                        {VM, 32-bit, RAM disk}
  3322. #    Examples:        CPUMemory := CPUstic();
  3323. #    Assumptions:    None
  3324. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  3325. #    History:
  3326. #        04/14/92    Richard Sheng    Created
  3327. #        03/30/94    Gary Kratzer    Added Modern Memory Manager check.
  3328. #        09/13/94    SBR                VU 2.1 Gestalt returns long integers; made changes for this.
  3329. #        09/27/96    BRL/MSO            Added SPEC exception handling
  3330. #########################################################################
  3331. task    CPUstic()
  3332. begin            
  3333.     if _Gestalt("mmu ")[2] > 1
  3334.         vmAvail := true;
  3335.     else
  3336.         vmAvail := false;
  3337.     
  3338.     if _Gestalt("addr")[2] = 0
  3339.         addressing := false;
  3340.     else
  3341.         addressing := true;
  3342.     
  3343.     temp := _Gestalt("mach")[2];
  3344.     if temp > 19 and temp <> 23
  3345.         RamDisk := true;
  3346.     else
  3347.         RamDisk:= false;
  3348.  
  3349.     temp := _Gestalt("cput");
  3350.     if temp[1] = 0
  3351.     begin
  3352.         if temp[2] >= 257    # If PowerPC 601 or greater (0x101 = PPC601)
  3353.             MMMgr := true;
  3354.     end;
  3355.     else                        # If cput isn't implemented, must be a 680x0
  3356.         MMMgr := false;
  3357.     
  3358.     return {vmAvail,addressing, RamDisk, MMMgr};
  3359. end;
  3360.  
  3361.  
  3362. #########################################################################
  3363. #    task                    restart_target(restart_flag, v_level)
  3364. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  3365. #    Description:    Restart the target machine.  This assumes we are in the
  3366. #                    Finder already, and returns a false value on failure.
  3367. #                    After restarting, it waits for the machine to respond
  3368. #                    before returning to the caller.
  3369. #    Parameters:        v_level:        verbosity level for log output
  3370. #    Returns:        Nothing
  3371. #    Examples:        restart_target();
  3372. #    Assumptions:    Target machine is in finder;
  3373. #                    no unsaved documents are open to prevent shutdown
  3374. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  3375. #    History:
  3376. #        7/25/90    Alan Liu    Creation as part of FinderLib.vu for 007
  3377. #        3/4/92    Jason Marsh    Incorporated into Clouseau.Lib
  3378. #        12/15/93    JDL        Added await presence for application 'finder'
  3379. #                            after target is found; documented assumptions
  3380. #        09/03/94    SBR        Added quit_all(), and error handling for target access
  3381. #        09/27/96    BRL/MSO    Added SPEC exception handling
  3382. #        04/17/97    SBR        Fixed Radar 1377545 (Special menu ordinality).
  3383. #########################################################################
  3384. task    restart_target(v_level := 5)
  3385. begin
  3386.     Err := false;                        #no error to begin with
  3387.  
  3388.     RStatus("restart_target: attempting to restart target...",2);
  3389.  
  3390.     theTarget := _Match([actor], true).u ;
  3391.     if not theTarget
  3392.     begin
  3393.         RError("restart_target: there is no target to restart!",2);
  3394.         return true;
  3395.     end;
  3396.         
  3397.     tName := theTarget.t;
  3398.     tZone := theTarget.z;
  3399.  
  3400.     # Only the Finder can be running to restart, for re-aquire to work.
  3401.     # We can not yet watch the applications close as they go by.
  3402.     quit_all(v_level);
  3403.  
  3404.     # Special menu is named funny with dev systems, have to use menu ordinality.
  3405.     # With System 8.x, the Special menu is ordinality 5. In System 7.x it is o:6.
  3406.     if _MatchBoolean( [menuItem t:'Restart' m:[menu o:5]], true)
  3407.         specialMenu := 5;
  3408.     else if _MatchBoolean( [menuItem t:'Restart' m:[menu o:6]], true)
  3409.         specialMenu := 6;
  3410.     else
  3411.         specialMenu := 0;
  3412.         
  3413.     if specialMenu
  3414.     begin
  3415.         try
  3416.         begin
  3417.             select [menuItem t:'Restart' m:[menu o:specialMenu]];
  3418.             releaseTarget(true);        #    Must release target IMMEDIATELY after selecting Restart
  3419.                                         #    Otherwise the target may be gone already - preventing
  3420.                                         #    successful reacquisition. Can't use select_menuitem.
  3421.         end;
  3422.         catch theError
  3423.             ExceptionDispatcher(theError,,{"select in restart_target", {v_level}});
  3424.             
  3425.         RStatus("Selected menu item 'Restart' in menu o:{specialMenu}",v_level);
  3426.         
  3427.         count := 0;
  3428.         while not (acqResult = 0 or count >= 5)
  3429.         begin
  3430.             wait(10);
  3431.             count := count + 1;
  3432.             acqResult := acquireTarget(tName, tZone);
  3433.             if acqResult = 2 acqResult := 0;
  3434.             if (acqResult <> 0)
  3435.                 RStatus("attempt {count} to acquire ∂"{tName}∂", result = {acqResult}",v_level);
  3436.         end;
  3437.         if count >= 5
  3438.             Err := true;
  3439.         (*wait for the target to start up again*)
  3440.         _Match ([target t:tName z:tZone]);    # update host model of the target
  3441.  
  3442.         await_presence([application t:"Finder"],30,5);
  3443.     end;
  3444.     else 
  3445.         Err := true;
  3446.     
  3447.     if Err
  3448.         RIncomplete("failed", v_level);
  3449.     else 
  3450.         RStatus("succeeded",v_level);
  3451.     return Err;
  3452. end;
  3453.  
  3454. #########################################################################
  3455. #    task            EH_CrashRecover(theError, parameterList, v_level)
  3456. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  3457. #    Description:    Standard error handler for -1100, -1104, or -1096 ScriptError() result. 
  3458. #                    This is intended to be used with the EveryTime macro in MacsBug, which 
  3459. #                    creates a MacsBug log. If expectedApp is Boolean true, ignore the app name
  3460. #                    but check for the MacsBug log. 
  3461. #    Parameters:        theError:        error that caused this handler to be called
  3462. #                    parameterList:    internally defined parameters for this handler
  3463. #                        {    expectedApp:    list of possible apps which might be in front
  3464. #                                            if we recovered from a "slow target crash"
  3465. #                            minTime:        minimum time to wait before each retry
  3466. #                            maxTime:        maximum time to wait for multiple retries
  3467. #                        }
  3468. #                    v_level:        verbosity level for log output
  3469. #    Returns:        report string
  3470. #    Assumptions:    VU 2.1, VUAid 2.1, FileTool, reset_target_info() was called
  3471. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  3472. #    History:
  3473. #        06/12/93    SBR        Created
  3474. #        09/03/94    SBR        Modified to use VU 2.1 - No NetworkRetries()
  3475. #        03/12/95    SBR        Modified to use VU 2.1 - error -1096, target restarted
  3476. #        09/27/96    BRL/MSO    Added SPEC exception handling
  3477. #########################################################################
  3478. task    EH_CrashRecover(theError, parameterList := {'',5,15}, v_level := 4)
  3479. begin
  3480.     global gMacsBugLogsFolder, gCurrentError;
  3481.     
  3482.     RStatus("EH_CrashRecover: error is {theError}, parameterList is {parameterList}.",v_level);
  3483.  
  3484.     expectedApp := parameterList[1];
  3485.     #minTime := parameterList[2];        #SBR 01/06/94: commented out for VM Stress
  3486.     #maxTime := parameterList[3];        #SBR 01/06/94: commented out for VM Stress
  3487.  
  3488.     tName := get_target_info('name');                    # can not use match; use stored values
  3489.     tZone := get_target_info('zone');
  3490.  
  3491.     try
  3492.         targetDesc := match[target t:tName z:tZone];
  3493.     catch theError
  3494.         if theError <> -1105
  3495.             ExceptionDispatcher(theError,,{"Match 1 in EH_CrashRecover", {theError, parameterList, v_level}});
  3496.  
  3497.     if not targetDesc
  3498.     begin
  3499.         crashed := "target failure (error = {theError})";
  3500.         RError("EH_CrashRecover: {crashed}", v_level);
  3501.         RStatus("EH_CrashRecover: TARGET '{tName}' CRASHED! WAITING FOR RESTART TO CONTINUE THE SCRIPT…",1);
  3502.     end;
  3503.     else if theError = -1096
  3504.     begin
  3505.         # -1096 means target restarted. VU 2.1 checks for this explicitly for each command
  3506.         
  3507.         crashed := "target restarted unexpectedly (error = {theError})";
  3508.         RError("EH_CrashRecover: {crashed}", v_level);
  3509.         RStatus("EH_CrashRecover: TARGET '{tName}' RESTARTED UNEXPECTEDLY!",1);
  3510.     end;
  3511.     else 
  3512.     begin
  3513.         RStatus( "EH_CrashRecover: Target recovered within " + 
  3514.                     "EH_CrashRecover({theError}, {parameterList}, {v_level})", v_level);
  3515.         RStatus( "EH_CrashRecover: Target descriptor is: {targetDesc}", v_level);
  3516.  
  3517.         crashed := "target failed and then recovered (error = {theError})";
  3518.         
  3519.         RError("EH_CrashRecover: {crashed}", v_level);
  3520.         RStatus("EH_CrashRecover: TARGET '{tName}' FAILED AND THEN RECOVERED!",1);
  3521.     end;
  3522.     
  3523.     releaseTarget(true);
  3524.     
  3525.     acqResult := acquireTarget(tName, tZone);
  3526.     while not (acqResult = 0)
  3527.     begin
  3528.         SysBeep();
  3529.         wait(20);
  3530.         acqResult := acquireTarget(tName, tZone);
  3531.         if acqResult = 2 
  3532.             acqResult := 0;
  3533.     end;
  3534.     
  3535.     #for cleanliness, restart the CPU
  3536.     RStatus("EH_CrashRecover: crashed target '{tZone}:{tName}' reaquired, restarting…", 1);
  3537.     twitch('Finder');
  3538.     
  3539.     # Wait for Desktop, i.e. Finder finishes launch, or else key_eq('w',5) is taken as "rebuild Desktop"
  3540.     desktopDescriptor := [window r:{0,0,0,0}];
  3541.     if not await_presence(desktopDescriptor, 60)
  3542.         RIncomplete("{desktopDescriptor} did not appear in 60 seconds",1);
  3543.     key_eq('w',5);                                    # close all windows
  3544.     
  3545.     mbLogName := MacsBugLog(expectedApp);
  3546.     if mbLogName 
  3547.         RStatus("EH_CrashRecover: MacsBug log is named {mbLogName}", 1);
  3548.  
  3549.     if restart_target()
  3550.         abort_script('EH_CrashRecover: the target did not restart properly');
  3551.     else
  3552.     begin
  3553.         setMacsBugMacro('restore');                # restore the MacsBug EveryTime macro
  3554.     end;
  3555.         
  3556.     return crashed;
  3557. end;
  3558.  
  3559. #########################################################################
  3560. #    task                setMacsBugMacro(theMacro, createLog, closeAndRestart, v_level)
  3561. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  3562. #    Description:    Uses VUAid 2.0 DebugStr service to set the MacsBug EveryTime macro.
  3563. #    Parameters:        theMacro:    A string of valid MacsBug commands, each followed by ';'.
  3564. #                                Keep it short, MacsBug is unforgiving for long macros!
  3565. #                                Also, avoid commands that produce more than a 
  3566. #                                screen full of output, or MacsBug will stop and ask
  3567. #                                for a key press to continue auto-scrolling.
  3568. #                                'clear':    special value; clear the EveryTime macro
  3569. #                                'read':        special value; read the stored macro
  3570. #                                'restore':    special value; restore EveryTime after restart
  3571. #                    createLog:    true:    log to "{startupVol}:{MBLogName}" while executing theMacro
  3572. #                                false:    execute theMacro directly without logging
  3573. #                    closeAndRestart:    true:  restart (close log if necessary)
  3574. #                                        false: allows tester to explore crashes manually
  3575. #                    v_level: verbosity level for reporting
  3576. #    Returns:        macro is set:        the EveryTime macro as currently stored, or,
  3577. #                                        'clear' for a cleared EveryTime macro
  3578. #                    macro is not set:    false or undefined
  3579. #    Examples:        setMacsBugMacro('ap;how;wh;ip;td;log;rs;');
  3580. #                    setMacsBugMacro('clear');        (clears the EveryTime macro)
  3581. #                    setMacsBugMacro('restore');        (restores macro to previous setting)
  3582. #                    setMacsBugMacro('',true,false);    (macro will open a blank log and wait)
  3583. #    Assumptions:    VU 2.1; no other volume has same name as startup volume 
  3584. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  3585. #    History:
  3586. #        06/12/93    SBR        Created
  3587. #        03/22/94    SBR        Changed so 'clear' is stored as 'clear' instead of empty string
  3588. #        09/03/94    SBR        Added error handling for target access.
  3589. #                            Uses VU 2.1 built-in DebugStr() task instead of VUAid.
  3590. #        08/14/95    SBR        Create a folder for new logs, see Radar 1277101.
  3591. #        09/27/96    BRL/MSO    Added SPEC exception handling
  3592. #########################################################################
  3593. task    setMacsBugMacro(theMacro := '', createLog := true, closeAndRestart := true, v_level := 2)
  3594. begin
  3595.     global g_EveryTime_Macro;            # the secret global which holds the Macro
  3596.     
  3597.     if theMacro = 'read'
  3598.         return g_EveryTime_Macro;
  3599.         
  3600.     if theMacro = 'clear'                # special case for 'clear'
  3601.         g_EveryTime_Macro := theMacro;
  3602.         
  3603.     else if theMacro = 'restore'
  3604.     begin
  3605.         if isUndefined(g_EveryTime_Macro)
  3606.         begin
  3607.             RError("You tried to 'restore' the MacsBug macro to an undefined value.",v_level);
  3608.             return false;
  3609.         end;
  3610.     end;
  3611.     else 
  3612.     begin                                # build a new macro and store it in g_EveryTime_Macro
  3613.         g_EveryTime_Macro := theMacro;
  3614.     
  3615.         if createLog
  3616.         begin
  3617.             startUpVol := get_target_info('startupVolume');
  3618.             mbLogName := get_target_info('MacsBugLogName');
  3619.             
  3620.             # Create a folder for new logs, see Radar 1277101.
  3621.             mbLogPath := "{startUpVol}:MacsBug Logs (new):{mbLogName}";
  3622.             
  3623.             g_EveryTime_Macro := "log ∂"{mbLogPath}∂";" + g_EveryTime_Macro;
  3624.             if closeAndRestart
  3625.                 g_EveryTime_Macro := g_EveryTime_Macro + "log;";
  3626.         end;
  3627.         
  3628.         if closeAndRestart
  3629.             g_EveryTime_Macro := g_EveryTime_Macro + "rs;";
  3630.     end;
  3631.     
  3632.     if g_EveryTime_Macro = 'clear'                    # special case for 'clear'
  3633.         theMacroString := ";mc EveryTime '';g;";
  3634.     else                                            # normal case for set and 'restore'
  3635.         theMacroString := ";mc EveryTime '{g_EveryTime_Macro}';set scrollprompt off;g;";
  3636.  
  3637.     _DebugStr( theMacroString, true );
  3638.  
  3639.     return g_EveryTime_Macro;
  3640. end;
  3641.  
  3642.  
  3643. #########################################################################
  3644. #    task                MacsBugLog(theName, v_level)
  3645. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  3646. #    Description:    Locate a file named "{mbLogName}" in the root directory of the 
  3647. #                    startup volume. If it exists, rename it "{thisHour} {theName}", and 
  3648. #                    move it to  "{startupVol}:MacsBug logs:{target} {thisMonth}/{thisDay}:".
  3649. #                    Folders are created if necessary.
  3650. #    Parameters:        theName:    anything but 'delete': rename and move as defined
  3651. #                                'delete': special value to delete "{mbLogName}"
  3652. #                    v_level: verbosity level for reporting
  3653. #    Returns:        new file name if successful, false if not
  3654. #    Examples:        MacsBugLog('TeachText 7.1');
  3655. #    Assumptions:    VU 2.1; no other volume has same name as startup volume; 
  3656. #                    FileTool is on the Target and launchable any time.
  3657. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  3658. #    History:
  3659. #        06/12/93    SBR        Created
  3660. #        07/19/93    SBR        Removes trailing '@' to prevent spurious finds
  3661. #        09/03/94    SBR        Added error handling for target access
  3662. #                            Use get_target_info instead of startUpVolWindow
  3663. #        09/17/96    BRL        Fixed error with folder name > 31 chars
  3664. #        09/27/96    BRL/MSO    Added SPEC exception handling
  3665. #########################################################################
  3666. task    MacsBugLog(theName := '', v_level := 4)
  3667. begin
  3668.     # Check if a macsbug log exists
  3669.  
  3670.     try
  3671.         match [mouse];
  3672.     catch theError
  3673.         if theError <> -1105
  3674.             ExceptionDispatcher(theError,,{"Match 1 in MacsBugLog()", {theName}});
  3675.  
  3676.     temp := FileTool('initialize', true);
  3677.     if temp[1]
  3678.         return RIncomplete("MacsBugLog: could not initialize FileTool");
  3679.         
  3680.     startupVolume := get_target_info('startupVolume');
  3681.     mbLogName := get_target_info('MacsBugLogName');
  3682.     mbLogPath := get_target_info('MacsBugLogPath');
  3683.     
  3684.     # If a log exists, rename it and move it to the logs folder
  3685.     if FileExists("{mbLogPath}:{mbLogName}")[2]
  3686.     begin
  3687.         if theName = 'delete'                        # delete the log
  3688.         begin
  3689.             DeleteFile("{mbLogPath}:{mbLogName}");
  3690.             theName := '';
  3691.         end;
  3692.         else 
  3693.         begin
  3694.             if not FileExists("{startupVolume}:MacsBug logs")[2]
  3695.                 CreateFolder("{startupVolume}:MacsBug logs");
  3696.         
  3697.             try 
  3698.                 match [time m:?thisMonth d:?thisDay h:?thisHour];
  3699.             catch theError
  3700.                 ExceptionDispatcher(theError,,{"match in MacsBugLog()", {theName, v_level}});
  3701.     
  3702.             tName := get_target_info('name');
  3703.             if not tName tName := actorName();
  3704.             mbLogsFolder := "{startupVolume}:MacsBug logs:{tName} {thisMonth}/{thisDay}";
  3705.             
  3706.             if not FileExists("{mbLogsFolder}")[2]
  3707.                 CreateFolder("{mbLogsFolder}");
  3708.     
  3709.             thisHour := "{thisHour}";                # pad to 4 characters
  3710.             thisHourLen := card thisHour;
  3711.             for i := 1 to 4 - thisHourLen
  3712.                 thisHour := '0' + thisHour;
  3713.             
  3714.             if not theName
  3715.                 theName := "MacsBug Log for ??";
  3716.             theName := "{thisHour} {theName}";
  3717.             nameLength := card theName;
  3718.             
  3719.             if theName[nameLength] = '@'            # remove '@' to prevent app mis-find
  3720.             begin
  3721.                 nameLength := nameLength - 1;
  3722.                 removeLastChar := true;
  3723.             end;
  3724.                 
  3725.             if nameLength > 31                        # if file name > 31, remove middle
  3726.                 tooLong := true;
  3727.                 
  3728.             if tooLong or removeLastChar            # for speed, process only if necessary
  3729.             begin
  3730.                 nameCopy := '';
  3731.                 for i := 1 to nameLength
  3732.                 begin
  3733.                     if tooLong
  3734.                     begin
  3735.                         if (i <= 20) or (i > 25)
  3736.                             nameCopy := nameCopy + theName[i];
  3737.                     end;
  3738.                     else nameCopy := nameCopy + theName[i];
  3739.                 end;
  3740.                 theName := nameCopy;
  3741.             end;
  3742.  
  3743.             MoveFile("{mbLogPath}:{mbLogName}","{mbLogsFolder}:{theName}" );
  3744.         end;
  3745.     end;
  3746.     else theName := '';
  3747.     
  3748.     FileTool('quit');            
  3749.     return theName;
  3750. end;
  3751.  
  3752.  
  3753. #########################################################################
  3754. #    task        EnableProgramLinking(pEnabled, pGuest, v_level)
  3755. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  3756. #    Description:    Starts Program Linking. Also enables program linking for 
  3757. #                    Guest users, if pGuest is true.
  3758. #    Parameters:        pEnabled:    true:    start program linking
  3759. #                                false:    stop program linking
  3760. #                    pGuest:    true:    turn on guest access
  3761. #                            false:    turn off guest access 
  3762. #                            undefined:    ignore guest access (may be on or off)
  3763. #                            
  3764. #                    v_level: verbosity level for reporting
  3765. #    Returns:        true if successful, false if not
  3766. #    Examples:        EnableProgramLinking(true, true);
  3767. #    Assumptions:    
  3768. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  3769. #    History:
  3770. #        03/12/97    SBR        Created
  3771. #        04/07/97    SBR        Updated for 8.0a5c6
  3772. #        05/30/97    SBR        Added pEnabled parameter.
  3773. #########################################################################
  3774. task EnableProgramLinking(pEnabled := true, pGuest := undefined, v_level := 4)
  3775. begin
  3776.     tSuccess := true;
  3777.     
  3778.     if pEnabled
  3779.     begin
  3780.         tStr1 := "About to start";
  3781.         tBeginStr := "Start";
  3782.         tEndStr := "Stop";
  3783.     end;
  3784.     else begin
  3785.         tStr1 := "About to stop";
  3786.         pGuest := undefined;
  3787.         tBeginStr := "Stop";
  3788.         tEndStr := "Start";
  3789.     end;
  3790.     
  3791.     if isUndefined(pGuest)
  3792.     begin
  3793.         tStr2 := "ignoring";
  3794.     end;
  3795.     else if pGuest 
  3796.     begin
  3797.         tStr2 := "enabling";
  3798.         tBeginVal := {0,1};
  3799.         tEndVal := {1,1};
  3800.     end;
  3801.     else 
  3802.     begin
  3803.         tStr2 := "disabling";
  3804.         tBeginVal := {1,1};
  3805.         tEndVal := {0,1};
  3806.     end;
  3807.     
  3808.     sysVersion := _Match([system]).v;
  3809.     if (sysVersion ~= /≈7.0≈/) or (sysVersion ~= /≈7.1≈/) or (sysVersion ~= /≈7.5≈/) or
  3810.             (sysVersion ~= /≈7.6≈/)
  3811.     begin
  3812.         newSharing := 0;        # Sharing Setup CP (controls visible)
  3813.     end;
  3814.     else if ((sysVersion ~= /≈7.7a2≈/) or (sysVersion ~= /≈7.7a3≈/) or 
  3815.                 (sysVersion ~= /≈8.0a4≈/))
  3816.     begin
  3817.         newSharing := 1;        # File Sharing CP (controls invisible to VU)
  3818.     end;
  3819.     else    #if (sysVersion ~= /≈8.0a5≈/) #See Radar 1646166.
  3820.     begin
  3821.         newSharing := 2;        # File Sharing CP (controls visible, not selectable)
  3822.     end;
  3823. #        else    # One day we might be able to use VU normally here.
  3824. #        begin
  3825. #            newSharing := 3;        # File Sharing CP (controls visible and selectable)
  3826. #        end;
  3827.         
  3828.     RStatus("{tStr1} Program Linking (type {newSharing}), {tStr2} guest access...",v_level);
  3829.     
  3830.     SavePreviousAppName := _Match([application ]).t;
  3831.  
  3832.     noFrontDialog := true;
  3833.     finderTwitchOK := twitch('Finder');                # Get to Finder, without a dialog
  3834.     if not finderTwitchOK
  3835.     begin
  3836.         tSuccess := false;
  3837.         RError("TurnOnProgramLinking: Could not switch to Finder, is a dialog in front?", 2);
  3838.     end;
  3839.     else 
  3840.     begin
  3841.         if ( _MatchBoolean( [window o:1 s:dialog], true) 
  3842.             or _MatchBoolean( [window o:1 s:movablemodal], true))
  3843.         begin
  3844.             noFrontDialog := dismiss_dialog();
  3845.         end;
  3846.     end;
  3847.         
  3848.     if finderTwitchOK and noFrontDialog
  3849.     begin
  3850.         if newSharing
  3851.         begin
  3852.             _Match([screen]);                            # Prepare for LocateString()
  3853.  
  3854.             SetTextOptions( { {"Charcoal",12}, {"Chicago",12}, {"Truth",12}} );
  3855.             
  3856.             open_control_panel("File Sharing",false);    # Do not close Control Panels window
  3857.             
  3858.             # Switch panels back and forth to stabilize control ordinalities.
  3859.             key_eq('tmt');                                # Switch to Start/Stop tab
  3860.             
  3861.             wBounds := _Match([window o:1]).b;        # Limit searches to window bounds rect
  3862.             
  3863.             # Get the search rectangle for the Program Linking Start/Stop button
  3864.             tRect := AwaitText({"Program Linking", wBounds},3);
  3865.             searchRect := {tRect[1], tRect[2], tRect[3], tRect[4] + 100};
  3866.                 
  3867.             switch newSharing
  3868.             begin
  3869.                 case 1:
  3870.                 begin
  3871.                     # System 7.7a4 and earlier builds: controls were invisible to VU 
  3872.                     
  3873.                     tRect := LocateText({tEndStr, searchRect});
  3874.                     if not tRect
  3875.                     begin
  3876.                         tRect := LocateText({tBeginStr, searchRect});
  3877.                         if not tRect
  3878.                         begin
  3879.                             RError("Could not determine if Program Linking is on or off.");
  3880.                             tSuccess := false;
  3881.                         end;
  3882.                         else
  3883.                         begin
  3884.                             move_mouse( { 'absolute',tRect,'click' } );
  3885.                             if not AwaitText({tEndStr, searchRect},20)
  3886.                             begin
  3887.                                 RError("Program Linking still off, 20 seconds after clicking {tBeginStr}.");
  3888.                                 tSuccess := false;
  3889.                             end;
  3890.                         end;
  3891.                     end;
  3892.                 end;
  3893.                 case 2:    
  3894.                 begin
  3895.                     # System 8.0(7.7)a5 and later builds: controls are visible to VU 
  3896.                     # Unfortunately, they are not selectable. Radar 1646166. 
  3897.                     
  3898.                     if _MatchBoolean([button t:tBeginStr o:4])    # Program linking button
  3899.                     begin
  3900.                         tRect := LocateText({tBeginStr, searchRect});
  3901.                         move_mouse( { 'absolute',tRect,'click' } );
  3902.                     end;
  3903.  
  3904.                     if not await_presence([button t:tEndStr o:4],20)    # Changes name for on/off
  3905.                     begin
  3906.                         RError("Program Linking unchanged 20 seconds after clicking {tBeginStr}.");
  3907.                         tSuccess := false;
  3908.                     end;
  3909.                 end;
  3910.                 default:    
  3911.                 begin
  3912.                     # System 8.0(7.7)a6? and later builds: controls are controllable by VU 
  3913.                     # We will assume this case does not exist until it is proven to exist.
  3914.                     
  3915.                     select_descriptor([button t:tBeginStr o:4]);    # Program linking button
  3916.  
  3917.                     if not await_presence([button t:tEndStr o:4],20)    # Changes name for on/off
  3918.                     begin
  3919.                         RError("Program Linking unchanged 20 seconds after clicking {tBeginStr}.");
  3920.                         tSuccess := false;
  3921.                     end;
  3922.                 end;
  3923.             end;
  3924.             key_eq('w');                                # Close File Sharing
  3925.             
  3926.             if not isUndefined(pGuest)
  3927.             begin
  3928.                 open_control_panel("Users & Groups");    # Close Control Panels window
  3929.                 
  3930.                 type_keys({'Guest', 'latch', commandKey, 'o'});
  3931.                 
  3932.                 await_presence([window t:"Guest" o:1]);
  3933.                 wBounds := _Match([window]).b;
  3934.                 
  3935.                 # Select "Sharing" from the popup.
  3936.                 move_mouse( {'absolute', LocateText({"Identity", wBounds}) } );
  3937.                 _PressMouse();
  3938.                 wait(0,0,0,500);
  3939.                 move_mouse( {'absolute', AwaitText({"Sharing", wBounds}) } );
  3940.                 wait(0,0,0,250);
  3941.                 _ReleaseMouse();
  3942.                 wait(0,0,0,500);
  3943.                 
  3944.                 switch newSharing
  3945.                 begin
  3946.                     case 1:
  3947.                     begin
  3948.                         # System 7.7a4 and earlier builds: controls were invisible to VU 
  3949.                     
  3950.                         # Assume that if we are here, Guest Program Linking is off.
  3951.                         # This is because VU can't see the checkbox setting to be sure.
  3952.                         move_mouse( {'absolute',  AwaitText({"Allow guests to link", 
  3953.                                         wBounds,{ {"Geneva",10} }}), 'click'} );
  3954.                     end;
  3955.                     case 2:
  3956.                     begin
  3957.                         # System 8.0(7.7)a5 and later builds: controls are visible to VU 
  3958.                         # Unfortunately, they are not selectable. Radar 1646166. 
  3959.  
  3960.                         if not _MatchBoolean([checkBox t:/Allow guests to link≈/ o:1 s:tEndVal])
  3961.                         begin
  3962.                             move_mouse( {'absolute',  AwaitText({"Allow guests to link", 
  3963.                                         wBounds,{ {"Geneva",10} }}), 'click'} );
  3964.                         end;
  3965.                     end;
  3966.                     default:
  3967.                     begin
  3968.                         # System 8.0GM? and later builds: controls are controllable by VU 
  3969.                         # The normal case (not yet proven).
  3970.                         
  3971.                         select_descriptor(
  3972.                                 [checkBox t:/Allow guests to link≈/ o:1 s:tBeginVal], 1);
  3973.                     end;
  3974.                 end;
  3975.  
  3976.                 # Close Guest then Users & Groups
  3977.                 key_eq('ww');
  3978.             end;
  3979.             else
  3980.                 key_eq('w');                                # Close Control Panels window
  3981.         end;
  3982.         else
  3983.         begin
  3984.             # System 7.6.1 and previous
  3985.             open_control_panel('Sharing Setup',false);    # Do not close Control Panels window
  3986.             select_descriptor([button t:tBeginStr o:1]);    # Program linking button
  3987.             await_presence([button t:tEndStr o:1],20);        # Changes name for on/off
  3988.             key_eq('w');                                # Close Sharing Setup
  3989.             
  3990.             if not IsUndefined(pGuest)
  3991.             begin
  3992.                 open_control_panel('Users & Groups');        # Close Control Panels window
  3993.                 type_keys({'<Guest>', 'latch', commandKey, 'o'});
  3994.                 select_descriptor([checkBox t:/Allow guests to link≈/ o:1 s:tBeginVal], 1);
  3995.                 key_eq('w');                                # Close <Guest>
  3996.                 type_keys({'wait1',returnKey});                # Sure you want to Save?
  3997.                 key_eq('w');                                # Close Users & Groups
  3998.             end;
  3999.             else
  4000.                 key_eq('w');                                # Close Control Panels window
  4001.         end;
  4002.         
  4003.         twitch(SavePreviousAppName);
  4004.         return tSuccess;
  4005.     end;
  4006.     else 
  4007.         return RError("EnableProgramLinking: Could not set it, is a dialog in front?", 2);
  4008. end;
  4009.  
  4010.  
  4011.